WePay

The /batch API calls

The following call lets you make multiple API calls with one HTTP request.

/batch/create

Creates a batch call that will allow you to make multiple API calls within a single API call. Each call will have a reference_id that can be used to identify that call. In addition, an access_token will be passed for each call in the list, allowing you to make batch API calls for multiple users.

The maximum number of API calls that you can make in a single batch call is 50 calls. In addition, you can make these calls without being throttled.

Arguments:

Parameter Required Type Description
client_id Yes Integer (64 bits) The ID for your API application. You can find it on your application's dashboard.
client_secret Yes String (255 chars) The secret for your API application. You can find it on your application's dashboard.
calls Yes Array of API calls An array of the API calls that you would like to make (see API call arguments below).

The API call arguments:

Parameter Required Type Description
call Yes String (255 chars) The name of the API call you want to make (ie. /checkout/find).
authorization Yes if the API call requires authorization String (255 chars) The access token of the user that is making the API call.
reference_id No String (255 chars) A unique id that you can attach to an API call so that you can specifically identify that call.
parameters Only if the API call requires parameters Array The parameters required by the API call that you specified in the "call" parameter.

Example:

{
   "client_id":12345,
   "client_secret":"abc123",
   "calls": [
          {
             "call":"/user",
             "authorization":"asd3522342f",
             "reference_id":"1341351",
             "parameters":{}
          },
          {
             "call":"/checkout/create",
             "authorization":"asd3522342f",
             "reference_id":23535111,
             "parameters":{
                "account_id":12345,
                "amount":100,
                "currency":"USD",
                "short_description":"test",
                "type":"goods"
             }
          }
   ]
}

Response:

Response Type Description
calls Array An array of responses to all the API calls made in the batch call.

Example:

{
   "calls": [
       {
         "call":"/user",
         "reference_id":"1341351",
         "response":{
            "user_id":54312,
            "email":"test@example.com",
            "first_name":"bob",
            "last_name":"smith"
         }
      },
      {
         "call":"/checkout/create",
         "reference_id":"23535111",
         "response":{
            "error":"access_denied",
            "error_description":"this account can no longer transact",
            "error_code":3004
         }
      }
   ]
}