Skip to content

Square: Create Card

Square cards.createCard: arguments, response, policy and SDK examples.

← Cards operations · Get started

Operation square.createcard

Provider route: POST /v2/cards. Alter supplies the connection’s credentials and routing.

Install @alter-ai/sdk @alter-ai/square with npm, or alter-sdk-square with pip. Supply your connected customer’s grant ID and the arguments described below.

import { App } from "@alter-ai/sdk";
import { SquareIntegration } from "@alter-ai/square";
async function execute(input: Parameters<SquareIntegration["cards"]["createCard"]>[0]) {
const app = new App({ apiKey: process.env.ALTER_API_KEY! });
try {
const provider = new SquareIntegration(app, { grantId: process.env.PROVIDER_GRANT_ID! });
const call = await provider.cards.createCard(input);
const result = await call.wait();
return result.bodyJson();
} finally {
await app.close();
}
}
import os
from alter_sdk import App
from alter_sdk_square import SquareIntegration
async def execute(arguments):
async with App(api_key=os.environ["ALTER_API_KEY"]) as app:
provider = SquareIntegration(app, {"grant_id": os.environ["PROVIDER_GRANT_ID"]})
call = await provider.cards.create_card(arguments)
result = await call.wait()
return result.body_json()
FieldTypePresenceDescription and constraints
$objectRootAdditional keys: not allowed
bodyModelRequired within parentExpand Create Card — request body — body

Referenced models: Create Card — request body — body

Response media type: application/json. The table describes the pinned successful response. Referenced models link to their complete fields.

FieldTypePresenceDescription and constraints
$ModelRootExpand Create Card — response body

Referenced models: Create Card — response body

6 more schemas are linked from the tables above, on the schema pages.

Create Card — request body — body
FieldTypePresenceDescription and constraints
$objectRootCreates a card from the source (payment token or payment id). Accessible via
HTTP requests at POST https://connect.squareup.com/v2/cards
cardModelRequired within parentExpand Create Card — request body — body card
Payment details associated with the card to be stored.
idempotency_keystringRequired within parentA unique string that identifies this CreateCard request. Keys can be
any valid string and must be unique for every request.

Max: 45 characters

See [Idempotency keys](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency) for more information.
Minimum length: 1
source_idstringRequired within parentThe ID of the source which represents the card information to be stored. This can be a card nonce or a payment id.
Maximum length: 16384
Minimum length: 1
verification_tokenstringOptionalAn identifying token generated by [Payments.verifyBuyer()](https://developer.squareup.com/reference/sdks/web/payments/objects/Payments#Payments.verifyBuyer).
Verification tokens encapsulate customer device information and 3-D Secure
challenge results to indicate that Square has verified the buyer identity.

See the [SCA Overview](https://developer.squareup.com/docs/sca-overview).

Referenced models: Create Card — request body — body card

Create Card — response body
FieldTypePresenceDescription and constraints
$objectRootDefines the fields that are included in the response body of
a request to the [CreateCard](api-endpoint:Cards-CreateCard) endpoint.

Note: if there are errors processing the request, the card field will not be
present.
cardModelOptionalExpand Create Card — response body — card
The card created by the request.
errorsarrayOptionalErrors resulting from the request.
errors[]ModelEach itemExpand Get Shift — response body — errors item

Referenced models: Create Card — response body — card, Get Shift — response body — errors item

Create Card — response body — card
FieldTypePresenceDescription and constraints
$objectRootRepresents the payment details of a card to be used for payments. These
details are determined by the payment token generated by Web Payments SDK.
billing_addressJSONOptional
billing_address (anyOf 1)ModelAlternativeExpand Get Payment — response body — payment billing address
The billing address for this card. `US` postal codes can be provided as a 5-digit zip code
or 9-digit ZIP+4 (example: `12345-6789`). For a full list of field meanings by country, see
[Working with Addresses](https://developer.squareup.com/docs/build-basics/common-data-types/working-with-addresses).
billing_address (anyOf 2)nullAlternative
binstringOptionalThe first six digits of the card number, known as the Bank Identification Number (BIN). Only the Payments API
returns this field.
Maximum length: 6
Read only: true
card_brandstringOptionalIndicates a card's brand, such as `VISA` or `MASTERCARD`.
The card's brand.
See [CardBrand](#type-cardbrand) for possible values
Known values: OTHER_BRAND, VISA, MASTERCARD, AMERICAN_EXPRESS, DISCOVER, DISCOVER_DINERS, JCB, CHINA_UNIONPAY, SQUARE_GIFT_CARD, SQUARE_CAPITAL_CARD, INTERAC, EFTPOS, FELICA, EBT, QUICPAY, ID, TRANSPORTATION_IC, CARNET
Read only: true
card_co_brandstringOptionalIndicates the brand for a co-branded card.
The card's co-brand if available. For example, an Afterpay virtual card would have a
co-brand of AFTERPAY.
See [CardCoBrand](#type-cardcobrand) for possible values
Known values: UNKNOWN, AFTERPAY, CLEARPAY
Read only: true
card_typestringOptionalIndicates a card's type, such as `CREDIT` or `DEBIT`.
The type of the card.
The Card object includes this field only in response to Payments API calls.
See [CardType](#type-cardtype) for possible values
Known values: UNKNOWN_CARD_TYPE, CREDIT, DEBIT
Read only: true
cardholder_nameJSONOptional
cardholder_name (anyOf 1)stringAlternativeThe name of the cardholder.
Maximum length: 96
cardholder_name (anyOf 2)nullAlternative
created_atstringOptionalTimestamp for when the card object was created on Square’s servers. In RFC 3339 format, e.g., "2016-09-04T23:59:33.123Z".
Read only: true
customer_idJSONOptional
customer_id (anyOf 1)stringAlternative**Required** The ID of a [customer](entity:Customer) to be associated with the card.
customer_id (anyOf 2)nullAlternative
disabled_atstringOptionalTimestamp for when the card object was disabled on Square’s servers. In RFC 3339 format, e.g., "2016-09-04T23:59:33.123Z".
Read only: true
enabledbooleanOptionalIndicates whether or not a card can be used for payments.
Read only: true
exp_monthJSONOptional
exp_month (anyOf 1)JSONAlternative
exp_month (anyOf 1) (anyOf 1)integerAlternativeThe expiration month of the associated card as an integer between 1 and 12.
Format: int64
exp_month (anyOf 1) (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
exp_month (anyOf 2)nullAlternative
exp_yearJSONOptional
exp_year (anyOf 1)JSONAlternative
exp_year (anyOf 1) (anyOf 1)integerAlternativeThe four-digit year of the card's expiration date.
Format: int64
exp_year (anyOf 1) (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
exp_year (anyOf 2)nullAlternative
fingerprintstringOptionalIntended as a Square-assigned identifier, based
on the card number, to identify the card across multiple locations within a
single application.
Maximum length: 255
Read only: true
hsa_fsabooleanOptionalIndicates whether the card is linked to a Health Savings Account (HSA) or Flexible
Spending Account (FSA), based on the card BIN.
Read only: true
idstringOptionalUnique ID for this card. Generated by Square.
Maximum length: 64
Read only: true
issuer_alertstringOptionalIndicates the type of issuer alert for a [card on file](entity:Card).
An alert from the issuing bank about the card status. Alerts can indicate whether
future charges to the card are likely to fail. For more information, see
[Manage Card on File Declines](https://developer.squareup.com/docs/cards-api/manage-card-on-file-declines).

This field is present only if there's an active issuer alert.
See [IssuerAlert](#type-issueralert) for possible values
Known values: ISSUER_ALERT_CARD_CLOSED
Read only: true
issuer_alert_atstringOptionalThe timestamp of when the current issuer alert was received and processed, in
RFC 3339 format.

This field is present only if there's an active issuer alert.
Read only: true
last_4stringOptionalThe last 4 digits of the card number.
Maximum length: 4
Read only: true
merchant_idstringOptionalThe ID of the merchant associated with the card.
Read only: true
prepaid_typestringOptionalIndicates a card's prepaid type, such as `NOT_PREPAID` or `PREPAID`.
Indicates whether the card is prepaid or not.
See [CardPrepaidType](#type-cardprepaidtype) for possible values
Known values: UNKNOWN_PREPAID_TYPE, NOT_PREPAID, PREPAID
Read only: true
reference_idJSONOptional
reference_id (anyOf 1)stringAlternativeAn optional user-defined reference ID that associates this card with
another entity in an external system. For example, a customer ID from an
external customer management system.
Maximum length: 128
reference_id (anyOf 2)nullAlternative
versionJSONOptional
version (anyOf 1)integerAlternativeCurrent version number of the card. Increments with each card update. Requests to update an
existing Card object will be rejected unless the version in the request matches the current
version for the Card.
Format: int64
version (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$

Referenced models: Get Payment — response body — payment billing address

Get Shift — response body — errors item
FieldTypePresenceDescription and constraints
$objectRootRepresents an error encountered during a request to the Connect API.

See [Handling errors](https://developer.squareup.com/docs/build-basics/handling-errors) for more information.
categorystringRequired within parentIndicates which high-level category of error has occurred during a
request to the Connect API.
The high-level category for the error.
See [ErrorCategory](#type-errorcategory) for possible values
Known values: API_ERROR, AUTHENTICATION_ERROR, INVALID_REQUEST_ERROR, RATE_LIMIT_ERROR, PAYMENT_METHOD_ERROR, REFUND_ERROR, MERCHANT_SUBSCRIPTION_ERROR, EXTERNAL_VENDOR_ERROR
codeModelRequired within parentExpand Get Shift — response body — errors item code
The specific code of the error.
See [ErrorCode](#type-errorcode) for possible values
detailstringOptionalA human-readable description of the error for debugging purposes.
fieldstringOptionalThe name of the field provided in the original request (if any) that
the error pertains to.

Referenced models: Get Shift — response body — errors item code

SDK function policy ID: square.createcard. Catalog operation: CreateCard. Rules can name either ID; function rules distinguish managed calls and conservatively cover raw calls sharing the route. Existing grant permissions and policy rules apply. wait() returns an immediate result or waits for a required approval; it never approves the request itself. Persist the approval ID to resume after a restart.

Provider errors retain their response; JSON decoding raises ProviderAPIError for provider failures. ManagedOperationError identifies contract/input/retention errors. See error handling and provider-specific behavior. Sensitive input may be refused before approval storage. A decoding error never resubmits a write.

Required provider scopes: ["PAYMENTS_WRITE"]

Pinned headers: {"Square-Version": "2026-11-18"}

Official provider source

Report an issue with this page

Necessary

Required for sign-in, security, authorization, and remembering your choices.

Always active

Analytics

Helps us understand how our website, product, and documentation are used.

Performance diagnostics

Uses performance tracing and privacy-masked session replay to diagnose problems.

Advertising

Shares visits and sign-ups with Meta, Reddit, and X so we can measure which of our ads work.

You can change these choices at any time from Cookie settings.