Get Started with Square APIs, SDKs, and Plugins
Square provides collections of APIs that work together to solve a variety of problems. Developers can build solutions using the Square platform to meet the business needs of Square sellers. This topic walks you through signing up for a Square account and testing Square APIs using the API Explorer tool and the Sandbox test environment.
On this page
To work with Square APIs, developers must first create a Square account. To create a account, go to the Let's create your account page and enter the required information.
When you sign up for a Square account, Square provides two dashboards:
Developer Dashboard. Use the Developer Dashboard to create and manage your applications, access the Sandbox Seller Dashboard, configure webhooks for real-time notifications, and perform other development tasks.
Seller Dashboard. The Seller Dashboard provides sellers with tools to manage daily business operations. A seller can control just about everything needed to ensure that the business is running smoothly.
In addition, there is a Sandbox Seller Dashboard for developers to use when testing APIs in the Square Sandbox. Developers access it through the Developer Dashboard. For more information, see Square Dashboard.
A developer must have an application in the Developer Dashboard.
A Square application enables external applications/solutions to connect to Square. An application can span a variety of use cases. In addition to managing credentials, you can manage webhook subscriptions, API versions, Apple Pay configuration, and so on. The API version defined in the application is the default Square API version. If an incoming request does not include an API version, the default is used.
You can create additional applications. Consider these examples:
You use the Square platform to create a web solution and a mobile solution. In this case, you might choose to create separate applications in your account.
You create independent solutions to manage different scenarios, such as manage orders and manage teams.
Follow these steps to create an application:
Sign in to the Developer Dashboard using your user name and password, and then create your first application by providing a name.
On the Applications page, choose Open for the application you created.
On the left navigation pane, choose the following pages and review the application configuration settings:
Credentials. Provides credentials you can use to authenticate requests. Separate credentials are provided for use in production and Sandbox testing. The API version identifies the version used in your solution. If an API request includes a version, it takes precedence. If the request does not include an API version, the version in the application configuration is used.
This access token has permissions to perform all Square API actions. You should not share the access token with others.
Locations. Displays the location ID for your Square account. Square creates the initial location ID based on information you provided during signup. Several Square APIs require your location ID. Therefore, in addition to the Seller Dashboard, the Developer Dashboard provides this information for convenience.
OAuth. Enables management of the OAuth workflow for your custom solutions.
In addition, the application maintains other information, such as a Webhooks page (for real-time notifications) and other API configurations. This topic does not go into details but provides links to relevant topics at the end.
You use the following to test a Square API request:
Square Sandbox. An isolated test environment.
API Explorer. It is an interactive tool you can use to send HTTP requests to Square. In this topic, you send HTTP requests to the Square Sandbox.
Before you deploy your own solutions to production, you can use these tools and environments to test APIs.
The Square account you created provides a default Sandbox test account. The test account provides an isolated environment that includes a test service (that mirrors the production environment), data storage for test data, and the Sandbox Seller Dashboard (separate from the production Seller Dashboard). When you make API calls using the Sandbox test account, you can verify those transactions in the associated Sandbox Seller Dashboard. These transactions do not affect your production data.
Open the Developer Dashboard and review the Applications page, as shown in the following example:
The Sandbox Test Accounts section shows the Default Test Account.
Choose … (ellipsis) and view the account details. Square creates this default test account in the same country as your Square account.
Choose Done to close Account Details.
Click Open next to Default Test Account to open the Sandbox Seller Dashboard that Square provided with the test account. It is similar to the production Seller Dashboard as explained in Step 1. Review and close the Sandbox Seller Dashboard.
You can now test an API call. For illustration, you make a Payments API call (
CreatePayment endpoint). To take a payment, the following information is required:
Payment source. One of the payment sources that the API supports is a nonce (a secure token that represents a payment source such a credit card). When you integrate Square payments in your web or mobile applications, the libraries you use generate a nonce from the card information. You then use the server-side Payments API to charge the nonce. For now, do not worry about generating a nonce. Square provides a test nonce (
cnon:card-nonce-ok) for Sandbox use. For more information, see Take Payments.
Amount details. This includes the amount and currency. You specify the currency that is valid for the region in which you created your Square account.
Authorization information. You use the Sandbox access token to authorize the request. This access token has full permissions so you can make the Payments API call.
Follow these steps to make the API call:
Get the Sandbox access token. The application you created in the preceding step provides you with the necessary credentials for Sandbox testing.
Sign in to the Developer Dashboard using your user name and password, and then create your first application.
Choose the application.
Choose Sandbox at the top of the page.
Copy the Sandbox Access Token.
(optional) Find the currency for your Square account. If you do not know the currency, call the Merchants API to get the account information:
Open API Explorer at https://developer.squareup.com/explorer/square.
Choose Merchants and List merchants from the drop-down menus.
Note that API Explorer, by default, uses the Sandbox domain (
connect.squareupsandbox.com) in the endpoint URL.
Provide the Sandbox Access token. Note that API Explorer provides two options:
You enter the Sandbox access token.
API Explorer gives you the option to sign in to your Square account. API Explorer then retrieves the application information and shows the available access tokens in a drop-down menu.
Choose Run Request to submit the request.
Review both the cURL Request and Response in the API Explorer UI. Note the
CreatePaymentrequest to take a payment.
In API Explorer, choose the API (Payments) and endpoint (Create Payment) from the drop-down menus.
Provide the Access token. It is your Sandbox access token.
Provide the following required request Body fields:
amount_money. Provide both the amount and currency field values. The amount is the smallest denomination of the currency. For example, when currency is USD, amount is in cents.
Idempotency_key. Provide a unique key or choose Generate.
source_id. Choose the fake nonce (
cnon:card-nonce-ok) provided for Sandbox testing.
Choose Run Request to send the request.
Review the following:
Request. It is the cURL command that created the payment.
Response. It shows the
Paymentobject created with
Square reports the preceding transaction in the Seller Dashboard. Because you tested the API in the Sandbox, you do not see this transaction in the production Seller Dashboard. Instead, Square reports the transaction in the Sandbox Seller Dashboard associated with the default Sandbox test account you used to take the payment.
Open the Developer Dashboard.
Choose Open next to Default Test Account. This opens the Sandbox Seller Dashboard associated with the default test account.
On the Transactions page, verify the preceding payment. Make sure you have the appropriate date range selected.
Now that you have signed up for a Square account, created an application, and tested some API requests, you can start building. The Square developer platform provides a collection of APIs and a variety of development tools:
Square API. Provides APIs for developers to build on the platform that sellers trust. This includes online payments, creating orders for itemized transactions, product catalog management, customer management, and employee time keeping.
Square Backend SDKs. Simplify development by encapsulating the Square API suites.
Payments SDKs. Square payments can be processed across multiple channels, including online, in-app, and in-person. The Square developer platform includes server-side APIs that support online payments and mobile SDKs that support mobile payments on seller or buyer mobile devices.
Square also supports Flutter and React Native for In-App and In-Person payments.
Webhooks. Supports push notifications for various Square APIs.
The tools and environments include: