Make your First API Call

After you create an account and application, you can use API Explorer to call Square APIs. This exercise creates a payment in the Square Sandbox.

Link to section

Create a payment

In the Developer Console, your application displays the following blue banner:

An image of the "create your first test payment" banner.

  1. Choose the Open API Explorer link on the banner. This opens API Explorer and populates all the fields that are required to send a CreatePayment request to the Payments API.

    Note

    Don't see the banner? Use this API Explorer link to open the prepopulated view.

  2. In API Explorer, choose Run Request.

  3. Review the Request and Response panes:

    • The Request pane shows the request that was sent. You can change the default cURL view to see the request in another programming language.
    • The Response pane shows the response from Square. If the payment is successful, Square returns a Payment object with the status field set to COMPLETED. If the request failed, Square returns an error.

An image of API Explorer populated with CreatePayment values.

The source_id in the request is a Sandbox payment token that represents a credit card. In production, payment tokens are generated by the Web Payments SDK or In-App Payments SDK. For more information, see Take Payments.

Did you know?

For this Get Started exercise, API Explorer prefilled the Access token field for you. In the future, after signing in, you need to choose an API and endpoint and then choose your access token.