Create Card in Sandbox

I’m trying to test creating a card using the Square sandbox with the Cards-Api and getting a “SERVICE_UNAVAILABLE” ApiError. Are we unable to create test cards in the sandbox?

I’m using the Web Payments SDK and one of the test cards to get a source ID (Everything appears to be working correctly around this).

And Here’s the request and response:

request: {
    method: 'POST',
    url: '',
    headers: {
      'user-agent': 'Square-TypeScript-SDK/13.0.0',
      'content-type': 'application/json',
      authorization: 'Bearer <MY-SQUARE-ACCESS-TOKEN>',
      'Square-Version': '2021-07-21',
      accept: 'application/json'
    body: {
      type: 'text',
      content: '{"idempotency_key":"\\u0018\\ufffdG\\ufffd-\\ufffdA\\ufffd\\ufffd\\ufffd$\\ufffdc\\u0016\\ufffd\\ufffd","source_id":"cnon:CBASEO1q4vlyvhh56lUQlo3uVec","card":{"cardholder_name":"Test Customer","customer_id":"79DJ3YVZ1RYGZ0WDHW8431G14G","reference_id":"611d8ba2637504a33d07de79"}}'
  statusCode: 503,
  headers: {
    'content-type': 'application/json',
    'square-version': '2021-07-21',
    vary: 'Origin, Accept-Encoding',
    'x-content-type-options': 'nosniff',
    'x-download-options': 'noopen',
    'x-frame-options': 'SAMEORIGIN',
    'x-permitted-cross-domain-policies': 'none',
    'x-speleo-traceid': 'FSYYQHdfkhCWJ',
    'x-xss-protection': '1; mode=block',
    date: 'Thu, 19 Aug 2021 00:21:36 GMT',
    'content-length': '124',
    'strict-transport-security': 'max-age=631152000; includeSubDomains; preload',
    connection: 'close'
  body: '{"errors":[{"category":"API_ERROR","code":"SERVICE_UNAVAILABLE","detail":"The Connect endpoint is currently unavailable."}]}',
  result: [Object: null prototype] { errors: [ [Object: null prototype] ] },
  errors: [
    [Object: null prototype] {
      category: 'API_ERROR',
      detail: 'The Connect endpoint is currently unavailable.'

A retry attempt yields the following error, which seems odd if the service was unavailable on the first request (I’m reusing the same idempotencyKey also):

errors: [
    [Object: null prototype] {
      category: 'INVALID_REQUEST_ERROR',
      code: 'SOURCE_USED',
      detail: 'Source was used before.',
      field: 'source_id'

It looks like I get the same errors outside of the sandbox in the production environment as well, so there must be something I’m doing wrong with my create card request. (I’m able to successfully create a customer in both environments).

It turns out my account wasn’t fully set up for payments and that was the issue–after finishing setting that up, the cards API seems to be fully working now :slightly_smiling_face:

Great! Please feel free to reach out if you have any additional questions. We’re happy to help. :slightly_smiling_face: