Skip to content

Integrations

Square SDK: get started

The complete Square API through typed application or agent clients

Use an ordinary App, or an Agent when the workload needs agent identity. Alter builds provider requests from a reviewed contract and applies the same connection authorization, policy, approvals, and audit records as raw requests.

Terminal window
npm install @alter-ai/sdk @alter-ai/square
# Python (installs core automatically)
pip install alter-sdk-square

The provider package includes only Square types and response schemas and pins its contract version.

Configure Square, request the scopes the application needs, and retain each customer’s grant ID after Connect consent. Alter supplies the credential; it never belongs in operation input.

import { App } from "@alter-ai/sdk";
import { SquareIntegration } from "@alter-ai/square";
const app = new App({ apiKey: process.env.ALTER_API_KEY! });
try {
const client = new SquareIntegration(app, { grantId: process.env.SQUARE_GRANT_ID! });
const result = await (await client.locations.listLocations({})).wait();
console.log(result.bodyJson());
} finally {
await app.close();
}
from alter_sdk import App
from alter_sdk_square import SquareIntegration
async def first_call(api_key: str, grant_id: str):
async with App(api_key=api_key) as app:
client = SquareIntegration(app, {"grant_id": grant_id})
call = await client.locations.list_locations({})
result = await call.wait()
return result.body_json()

Contract 2026-11-18 publishes 318 operations from the pinned official OpenAPI document. The two OAuth credential operations and 12 application-token-only Events and Webhook Subscriptions operations are excluded from this seller OAuth SDK. The API reference links every operation to its complete input fields, response models, TypeScript and Python examples, and policy identity. Browse by resource under this provider’s API reference in the Integrations sidebar, or download the pinned OpenAPI specification. The Developer Portal provider view and alter integrations operations square --version 2026-11-18 also expose the schemas.

Generated calls pin the Alter contract version. Square’s own product, role, scope and subscription requirements still apply. There is no silent version fallback and no automatic write retry or pagination.

Terminal window
alter integrations execute square square.listlocations \
--version 2026-11-18 --grant "$SQUARE_GRANT_ID" --input '{}' --wait

Arguments use native path, query, headers, and body containers. This publication has no array-valued query parameters. SDK methods preserve provider field names and exact numeric values. Supply an int64 input beyond JavaScript’s safe integer range as a decimal string in either SDK; Alter converts it to a native JSON integer before Square receives it. The signed 64-bit range and any narrower field bounds are enforced. Unsafe JavaScript numbers are rejected. Large response numbers remain exact strings. HTTP 204 returns null / None from the typed decoder. Binary responses use bodyBytes() / body_bytes(); the CLI can save them with --output-file.

A policy rule can require approval for any operation. The call returns a pending approval; wait() resolves once the approver decides, and resume(approvalId) picks a pending approval up after a restart. Approval cards show the operation, its contract version and the request input the sensitivity review marked safe to display.

catalog.createCatalogImage, catalog.updateCatalogImage, disputes.createDisputeEvidenceFile, and invoices.createInvoiceAttachment accept a body containing a JSON request part and a file object with filename, content_type, and content_base64. Python uses the corresponding snake_case method names. Each endpoint validates its documented file media types. The serialized input must fit the shared 5 MiB limit, including base64 expansion.

Private evidence and invoice attachments are masked and held when approval is required. Catalog image uploads retain their reviewed treatment as product assets. File bytes are never shown on an approval card or captured as a raw binary body.

Families describe each operation’s effects. Charges, refunds, payable invoices, stored-value changes, compensation changes and billing definitions carry payment. Sending invoices, receipts, booking notifications or shipment notifications carries send. Access and visibility changes carry admin. Creating a checkout link alone does not send it. Each operation’s reference lists its exact families and supported policy selectors; amounts, currencies and distinct money roles remain separate selectors.

UpdateTeamMember and BulkUpdateTeamMembers require an explicit credential_minting allowance only when an existing member is set to status: "ACTIVE" or an assigned_locations key is supplied, including null or empty assignments. Square documents that ACTIVE enables sign-in and assigned locations determine where existing permissions apply. A bulk request is gated if any member changes those access controls; unreadable or unreviewed inputs fail closed. Ordinary name, contact and wage edits, and INACTIVE-only updates, pass without that allowance when no other rule denies them. CreateTeamMember and BulkCreateTeamMembers remain unmarked: Square requires separate Dashboard permission and passcode setup before a new profile gains usable account access. Their existing policy families and ordinary rules still apply.

Nested catalog objects and bulk request maps retain their native structure. Repeated scalar values must be unambiguous for a scalar policy condition; customer, team, vendor and shift IDs used as map keys are available as reviewed target sets. Projection does not silently truncate recursive objects.

Private addresses, phone numbers, customer notes, arbitrary custom values, narrow payment tokens and credential material are masked according to the operation review. Payload capture follows the application’s setting with reviewed sensitive fields removed; credential and raw payment-secret exclusions still apply. Responses containing usable payment, invoice, card, bank-account, gift-card, device-pairing or webhook-signing secrets are marked secret_output; their payload capture is withheld, not merely masked. General OAuth token creation and revocation remain credential operations and are not SDK methods.

Events and Webhook Subscriptions require an application personal access token. This OAuth integration explicitly refuses those 12 routes; a seller grant cannot supply that credential.

Square normally reports failures using HTTP error statuses. Its bulk APIs can return HTTP 200 with per-item errors: a wholly failed batch is reported as a provider fault, while a mixed successful/failed batch remains a typed result whose per-item errors the caller must inspect. Catalog batch upsert likewise fails when errors are returned without any created objects. Alter never automatically retries a write.

The pinned official source, its hash, the generated methods and the policy mapping are checked together. Scheduled checks save upstream candidates and report additions, removals and schema changes; they never replace a published contract automatically. Existing contract versions remain available for installed SDKs and pending approvals.

Persist call.approvalId (TypeScript) or call.approval_id (Python), then construct a fresh provider client and call resume(savedId), followed by wait(). The stored approval selects the operation; this installed package verifies its provider and contract version before attaching the response validator. Mismatches raise ManagedOperationError, never silently decode using another contract. See persist-and-resume examples.

Policy operation fields also accept the published SDK function IDs listed by alter integrations operations square. Use when.operation for a json_match or conditional require_approval rule, or match.operations for content_match (including redaction and step-up). Conditional approval can also use when.match.operations with parameter conditions. alter policy simulate --operation <function-id> tests that exact function.

Managed calls carry a server-verified function identity. Alter still evaluates policy against the actual method, URL and body after building the request from the authorized connection. Existing endpoint, method, host, catalog-operation and family rules continue to apply unchanged. A raw call can share an endpoint with several SDK functions and matches all of them; a function name never grants permission or bypasses existing restrictions.

For example, this rule requires approval for one function:

{
"effect": "require_approval",
"when": { "operation": "square.createcustomer" },
"approval": { "approvers": ["reviewer@example.com"] }
}

Save it with alter policy rules create --app <app-id> --grant <grant-id> --type require_approval --body @rule.json, or select the function in the portal.

This release replaces 685 parameter-selector names across 126 operations and changes 68 operation family sets from the previous catalog. Device-code routes no longer carry the default credential refusal; their pairing-code responses still withhold payload capture. Capture is additionally withheld on 20 payment, invoice, card and bank-account routes because their responses can contain narrow secrets. CreateSubscription no longer accepts the obsolete plan_id field; use plan_variation_id.

Before using this catalog, update stored rules to the selector names in the generated operation reference and recheck their family matches. Every payment operation also carries write, including deletions. Each repeated amount control has a separately named _max selector for its largest individual amount: use it for thresholds across differently priced line items; it is not an order total. Existing scalar selectors remain independently available. Review device-code permissions explicitly and expect captures to be absent on the protected routes even when capture is enabled for the application.

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.