---
title: Multirequest
url: https://docs.kaltura.com/docs/getting-started/general/api-multirequest
---

## Multirequest — Batching API Calls

Combine multiple API calls into a single HTTP request using the multirequest endpoint. Each sub-request can reference results from previous sub-requests using `{N:result:property}` chaining.

**Endpoint:** `POST $KALTURA_SERVICE_URL/service/multirequest`

**How it works:**

- Number each sub-request starting from 1: `1:service`, `1:action`, `2:service`, `2:action`
- Chain outputs: `2:entryId={1:result:id}` passes request 1's `id` into request 2's `entryId`
- The response is a JSON array with one result per sub-request

**Example: Create entry + add content in one call:**

```bash
curl -X POST "$KALTURA_SERVICE_URL/service/multirequest" \
  -d "format=1" \
  -d "ks=$KALTURA_KS" \
  -d "1:service=uploadToken" \
  -d "1:action=add" \
  -d "2:service=media" \
  -d "2:action=add" \
  -d "2:entry[objectType]=KalturaMediaEntry" \
  -d "2:entry[name]=My Video" \
  -d "2:entry[mediaType]=1" \
  -d "3:service=media" \
  -d "3:action=addContent" \
  -d "3:entryId={2:result:id}" \
  -d "3:resource[objectType]=KalturaUploadedFileTokenResource" \
  -d "3:resource[token]={1:result:id}"
```

**Response:** Array of results — one per sub-request:

```json
[
  { "id": "0_uploadtoken123", "objectType": "KalturaUploadToken" },
  { "id": "1_newentry456", "name": "My Video", "objectType": "KalturaMediaEntry" },
  { "id": "1_newentry456", "objectType": "KalturaMediaEntry" }
]
```

**Error handling:** Each sub-request can fail independently. Check each array element for `objectType: "KalturaAPIException"`:

```json
[
  { "id": "0_token123", "objectType": "KalturaUploadToken" },
  { "code": "INVALID_ENTRY_ID", "message": "...", "objectType": "KalturaAPIException" }
]
```

**When to use multirequest:**

- **Use when** subsequent calls depend on prior results (chaining), when reducing round trips matters for latency-sensitive operations, or when you need to guarantee atomicity of a sequence of related calls.  
- **Avoid when** calls are independent and can run in parallel from your client, when the total payload becomes very large, or when you need individual error recovery per call (a multirequest either succeeds or fails as a unit at the HTTP level, though individual sub-requests can fail independently within the response array).  
- **Common patterns:** Upload workflows (create token + entry + attach content), creating entries with metadata and categories, any sequential workflow where each step uses a result from the previous step.
