Build with Square

Get Started with Square APIs, SDKs, and Plugins

Step 1: Create a Square account Permalink Get a link to this section

Square provides collections of APIs that work together to solve a variety of problems, including online payments (eCommerce), in-person payments (point of sale), product management, customer management, and business management.

To work with Square APIs, you must create a Square account or sign in to an existing account.

Important

Square API support for credit card and card on file processing is currently limited to the United States, Canada, Japan, Australia, and the United Kingdom.

Cash payments and non-payment API functionality (such as, employee management, timecards, and catalogs) are supported everywhere Square accounts are available.

Step 2: Create a new application Permalink Get a link to this section

To create a new application:

  1. Open the Developer Dashboard.

  2. Choose New Application or choose Create Your First Application if your account is new.

  3. Enter a name for your application.

  4. Agree to the Square Developer Terms of Service.

  5. Choose Create Application.

Note

You can test payment processing in the Sandbox right away. To process payments in production, you need to visit squareup.com/activate to activate payment processing on the target account or Square returns an error.

Step 3: Get to know the application settings pages Permalink Get a link to this section

Choose the application you created in step 2 to open the application settings pages. The application settings pages includes multiple pages with different values and settings you might need while developing your application:

  • Credentials. Manage application credentials for production and the Sandbox.

  • OAuth. Manage the OAuth workflow for your custom solution.

  • Webhooks. Configure and enable webhooks.

  • Reader SDK. Configure the Reader SDK for your custom mobile solution.

  • Point of Sale API. Configure the Point of Sale API for your custom mobile solution.

  • Apple Pay. Configure Apple Pay on the Web for eCommerce solutions using the Square payment form.

  • Locations. Display production and Sandbox location IDs for the Square account. Location IDs are listed in the application control panel for convenience.

Important

The Developer Dashboard is defaulted to Sandbox mode and provides application credentials for the Sandbox environment. When you are ready to deploy your application to the production environment, set Developer Dashboard to Production mode and replace the Sandbox credentials in your application configuration code with production credentials.

Step 4: Understand the different application credentials Permalink Get a link to this section

The application settings pages provide a variety of credentials for accessing Square services. You need to use different credentials depending on how your application is used.

To learn about different application credentials, see Application credential types.

Step 5: Try it out Permalink Get a link to this section

Use your Sandbox access token and location ID with the tool below to send a Payment request with a test nonce to process a credit card payment.

Get application Sandbox credentials Permalink Get a link to this section

  1. Open the Developer Dashboard and select an application. The Credentials page for the selected application is shown.

  2. Set the dashboard to Production mode for a production application ID or to Sandbox mode for a Sandbox application ID (used in testing).

  3. Copy the Sandbox Application ID and the Sandbox Access Token in the Credentials section of the page.

Command line Permalink Get a link to this section

If you are using a Mac, open a Terminal. If using Windows, open a PowerShell session.

  1. Update the Authorization header by replacing {{ACCESS_TOKEN}} with your Sandbox Personal Access Token.

  2. Update the default JSON block in the payload of the command:

    • Set idempotency_key to any unique string, for example TESTKEY123.

    • Set source_id to cnon:card-nonce-ok.

  3. Copy the command and paste it into the command line.

  4. Run the command.

Terminal Permalink Get a link to this section

curl -X POST \
-H 'Accept: application/json' \
-H 'Authorization: Bearer {{ACCESS_TOKEN}}' \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-d '{
    "idempotency_key": "{{UNIQUE-KEY}}",
    "autocomplete": true,
    "amount_money": {
      "amount": 100,
      "currency": "USD"
    },
    "source_id": "cnon:card-nonce-ok"
    }
}' \
'https://connect.squareupsandbox.com/v2/payments'

PowerShell Permalink Get a link to this section

$authHeader = @{ Authorization = 'Bearer  {0}' -f "{{ACCESS_TOKEN}}" }
$body = '{
    "idempotency_key": "{{UNIQUE-KEY}}",
    "autocomplete": true,
    "amount_money": {
      "amount": 100,
      "currency": "USD"
    },
    "source_id": "cnon:card-nonce-ok"
    }
}'

Invoke-RestMethod -Uri https://connect.squareupsandbox.com/v2/payments |
   -Method Post |
   -ContentType "application/json" |
   -Headers $authHeader |
   -Body $body 

Step 6: Start building Permalink Get a link to this section

The Square developer platform provides a variety of development tools:

  • Square API Suite. Supports online payments, order creation for itemized transactions, product catalog management, customer management, and employee time keeping.

  • Webhooks. Supports push notifications for the Square Catalog, Inventory, and Labor APIs.

  • Sandbox. Supports the Square API suite in an isolated Sandbox testing environment. Also supports webhook notifications on API operations in the Sandbox environment.

  • Square SDKs. Simplify development by encapsulating the Connect v1 and Square API suites. Square SDKs are available for PHP, Node.js, Ruby, Python, Java, and .NET.

  • Connect v1 API Suite. Most of the v1 endpoints are deprecated and replaced with Square API endpoints. Connect v1 is provided primarily for backward compatibility. Existing v1 application developers can use Square API Migration Guides to learn about migrating to the Square API suite.

  • Mobile APIs and SDKs. Support in-person payments for mobile web and custom mobile applications:

    • Reader SDK. Accepts payments in native Android and iOS applications.

    • Point of Sale API. Calls the Square Point of Sale application from native Android and iOS and from mobile web applications.

    • In-App Payments SDK. Accepts payments in native Android and iOS applications on buyer devices.

  • Open Source Plugins. Support development in multi-platform application development frameworks. Plugins are available for Reader SDK (Flutter and React Native) and In-App Payments SDK (Flutter and React Native).

    Did you know?

    You can use HTTPS request tools like API Explorer, Postman, Paw, and Insomnia to quickly and easily test API requests during development. HTTPS request tools provide customized environments and parameterization of API calls that let you call endpoints without having to write code.

    For more information about using our preconfigured API collections, see Test Square APIs with Postman.