Build with Square

Get Started with Square APIs, SDKs, and Plugins

Start building with Square in 6 easy steps.

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 login 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 (e.g., employee management, timecards, catalog) is 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 Application Dashboard.

  2. Click New Application (or Create Your First Application if your account is brand new).

  3. Enter a name for your application.

  4. Agree to the Square Developer Terms of Service

  5. Click Create Application.

Note

You can process payments 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 will return an error.

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

Click on 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 may need while developing your application:

  • Credentials — manage application credentials for production and 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 Application Dashboard is defaulted to the Sandbox Settings mode. When you are ready to deploy your app to production, set dashboard to Production Settings mode and replace the sandbox credentials in your app 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 will need to use different credentials depending on how your application will be used.

Read about Square application credential types to learn about different application credentials.

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 Application Dashboard and select an application. The Credentials page for the selected app is shown.

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

  3. Copy the Application ID in the Credentials section of the page.


Developer Dashboard in Sandbox Settings mode image-test sandbox-01@2x


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

Square Developer Platform provides a variety of development tools:

  • Connect v1 API Suite — supports webhooks and employee management. Payment, timecard, and item management functionality in the v1 suite is still fully supported but provided primarily for backward compatibility. New applications should use the Connect v2 API Suite for payments, timecards, and item management.

  • Connect v2 API Suite — supports online payments, order creation for itemized transactions, product catalog management, customer management, and employee time keeping.

  • v2 Webhooks — supports push notifications for Connect v2 catalog and inventory APIs.

  • v2 Sandbox (beta) — supports the Connect v2 API suite in an isolated sandbox testing environment. Also supports v2 Webhook notifications on API operations in the v2 Sandbox (beta) environment.

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

  • Mobile APIs and SDKs — support in-person payments for mobile web and custom mobile applications:

    • Point of Sale API — calls the Square Point of Sale app from native Android and iOS, and mobile web apps.

    • Reader SDK — accepts payments in native Android and iOS apps.

    • In-App Payments SDK — accepts payments in native Android and iOS apps on customer personal devices.

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

Did you know?

You can use HTTPS request tools like Postman, Paw or 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.

See Testing Square APIs with Postman for more information on using our pre-configured API collections.