Batch

POST/v1/{appId}/batch

You can use the batch endpoint to perform multiple operations with a single REST call. You can include a maximum of 10 operations in a single batch request.

Replace {appId} in the baseUrl with your own App ID, which you can find under Settings in your TalkJS dashboard.

Payload

The payload is an array of operations. Each operation has the format:

1[sequence_number, method, path, payload, options]
NameTypeDescriptionExample
sequence_numbernumberUnique identifier of the operation. Can be any number.1
methodstringIndicates the HTTP method for the operation.GET
pathstringPath of the REST API endpoint for the operation that's appended to the /v1/{appId} baseUrl./users/user_01
payload (optional)objectJSON payload. You can use this for PUT and POST requests to specify the payload associated with the REST API operation. You can also use it with string keys and values to specify query parameters to filter results of a GET request.{ name: "Alice" }
options (optional)objectMapping containing the key api_version, and a string value with the API version.{"api_version": "2021-01-01"}
POST/v1/{appId}/batch
1type Operation = [
2 sequence_number: number,
3 method: string,
4 path: string,
5 payload?: any,
6 options?: {"api_version": string}
7]
8
9type Payload = Operation[];

The operations may execute in a different order than the one specified in the request. If you have operations that need to happen in a certain order (for example, first creating a user and then setting them as a participant to a conversation), then you need to request those in separate calls.

Response

The response will be an array of operation responses. Each operation response has the format:

1[sequence_number, http_status_code, operation_response]
NameTypeDescriptionExample
sequence_numbernumberUnique identifier of the operation. Corresponds to the sequence_number in the request.1
http_status_codenumberNumeric HTTP status code for the REST operation.200
operation_responsestringThe JSON data returned by the REST operation.[{"id": "msg_1821ZuPQL8tqKUWqXp8YDF"}]
POST/v1/{appId}/batch
1type OperationResponse = [
2 sequence_number: number,
3 http_status_code: number,
4 operation_response: any
5]
6
7type Response = OperationResponse[];