Search code examples
square-connect

Square API: Batch request to Subscriptions endpoint


The Square Subscriptions endpoint works differently from other Square API endpoints. The url begins with /oauth2 and requires a special Authorization header to be provided.

Because of these differences, is it possible to include a GET to the Subscriptions endpoint in a Batch request? All of my efforts so far have failed.


Here is my POST body to the Batch endpoint:

{
  "requests": [
    {
      "method": "GET",
      "relative_path": "/oauth2/clients/MY_CLIENT_ID/subscriptions/SUBSCRIPTION_ID",
      "access_token": "Client APPLICATION_SECRET",
      "request_id": "MyRequestID"
    }
  ]
}

And here is the response:

[
  {
    "status_code": "400",
    "type": "bad_request",
    "message": "invalid endpoint",
    "request_id": "MyRequestID"
  }
]

Solution

  • Unfortunately the oauth API endpoints are separate from the rest of the Connect API, and aren't supported by the batch endpoint. If you need to make a lot of requests to this endpoint in a short period, you will have to dispatch them in parallel.