algolia-api-reference/08-ops-security-api.md
Indexing wzxhzdk:46 Objects API — Algolia API Reference
Writing and managing records and indices: add / replace / partial-update records, batch operations, deletes, index lifecycle (copy / move / list / delete), and the async task model that ties it all together.
This file documents two equivalent ways to call every operation:
- Raw REST —
METHOD /pathagainst the Algolia write host, with auth headers and acurlexample. - MCP tool — the
mcp__algolia__*tool, its parameter object, and an example call.
Base hosts wzxhzdk:47 authentication
| Concern | Value |
|---|---|
| Write/indexing host | https://$ALGOLIA_APP_ID.algolia.net |
| DSN read host | https://$ALGOLIA_APP_ID-dsn.algolia.net |
| Retry fallback hosts | https://$ALGOLIA_APP_ID-1.algolianet.com, -2, -3 |
| API version prefix | /1/ in every path |
| App ID header | X-Algolia-Application-Id: $ALGOLIA_APP_ID |
| API key header | X-Algolia-API-Key: $ALGOLIA_API_KEY |
wzxhzdk:48 Header casing is not significant; the official docs render them lowercase
wzxhzdk:49 (x-algolia-application-id, x-algolia-api-key). Both forms are accepted.
Two credential contexts live in .env.local (never hardcode keys — always reference the env vars):
- CENTRAL →
ALGOLIA_CENTRAL_APP_ID,ALGOLIA_CENTRAL_API_KEY - VISIBILITY →
VISIBILITY_APP_ID,VISIBILITY_API_KEY
In the examples below, $ALGOLIA_APP_ID / $ALGOLIA_API_KEY stand for whichever context applies.
For MCP tools, the context is selected via the applicationId parameter.
Source (base hosts + auth): https://www.algolia.com/doc/rest-api/search/
Writing records
saveObject — add a record (auto-generated objectID)
Purpose: Add a brand-new record and let Algolia generate its objectID. Use when you do not
control / care about the record's ID.
REST: POST /1/indexes/{indexName} (host https://$ALGOLIA_APP_ID.algolia.net)
ACL required: addObject
MCP tool: mcp__algolia__saveObject
Key parameters:
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
applicationId |
string | yes | — | Algolia app ID (MCP only; selects credential context) |
indexName |
string | yes | — | Target index (case-sensitive) |
requestBody |
object | yes | — | The record. Schemaless object of search/discovery attributes |
curl example:
wzxhzdk:0
Response (201 Created):
wzxhzdk:1
MCP call example:
wzxhzdk:2
Source: https://www.algolia.com/doc/rest-api/search/save-object
addOrUpdateObject — add or replace a record (with objectID)
Purpose: Create the record if it doesn't exist, or fully replace it if it does. This is a full overwrite — any attribute not present in the body is removed from the record.
REST: PUT /1/indexes/{indexName}/{objectID} (host https://$ALGOLIA_APP_ID.algolia.net)
ACL required: addObject
MCP tool: mcp__algolia__addOrUpdateObject
Key parameters:
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
applicationId |
string | yes | — | Algolia app ID (MCP only) |
indexName |
string | yes | — | Target index |
objectID |
string | yes | — | Unique record identifier (path param) |
requestBody |
object | yes | — | Full record. Replaces the existing record entirely |
curl example:
wzxhzdk:3
Response (200 OK):
wzxhzdk:4
MCP call example:
wzxhzdk:5
Source: https://www.algolia.com/doc/rest-api/search/add-or-update-object
partialUpdateObject — add or update attributes
Purpose: Update only the attributes you name, leaving the rest of the record untouched.
Opposite of addOrUpdateObject (which replaces the whole record). Supports built-in operations on
attributes (e.g. Increment, Decrement, Add, Remove, AddUnique, IncrementFrom, IncrementSet).
REST: POST /1/indexes/{indexName}/{objectID}/partial (host https://$ALGOLIA_APP_ID.algolia.net)
ACL required: addObject
Query param: createIfNotExists (boolean, default true) — if false, the call is a no-op when the record doesn't exist.
MCP tool: mcp__algolia__partialUpdateObject
Key parameters:
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
applicationId |
string | yes | — | Algolia app ID (MCP only) |
| `indexName` | string | yes | — | Target index |
| `objectID` | string | yes | — | |
| `requestBody` | object | yes | — | |
| `createIfNotExists` | boolean | no | `true` |
**curl example:**
wzxhzdk:6
**Response (200 OK):**
wzxhzdk:7
**MCP call example:**
wzxhzdk:8
**Source:** https://www.algolia.com/doc/rest-api/search/add-or-update-object (related: https://www.algolia.com/doc/api-reference/api-methods/partial-update-objects/)
Batch operations
batch — multiple operations on ONE index
**Purpose:** Add, update, partially-update, or delete many records in a single index in one request. This is the workhorse for bulk indexing — far faster than per-record calls.
**REST:** `POST /1/indexes/{indexName}/batch` (host `https://$ALGOLIA_APP_ID.algolia.net`) ACL required: `addObject`
**MCP tool:** `mcp__algolia__batch`
**Key parameters:**
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| `applicationId` | string | yes | — | Algolia app ID (MCP only) |
| `indexName` | string | yes | — | Target index |
| `requestBody.requests` | array | yes | — | List of `{ action, body }` operations |
| `requests[].action` | enum | yes | — | One of the action types below |
| `requests[].body` | object | yes | — | Operation arguments (shape depends on `action`) |
**Action types** (same set for `batch` and `multipleBatch`):
| Action | Effect |
|---|---|
| `addObject` | Add a record (auto objectID if none given) |
| `updateObject` | Add or fully replace a record (objectID required) |
| `partialUpdateObject` | Update named attributes; **creates** record if missing |
| `partialUpdateObjectNoCreate` | Update named attributes; **does not** create if missing |
| `deleteObject` | Delete a record by objectID |
| `delete` | Delete the entire index |
| `clear` | Delete all records from the index |
**curl example:**
wzxhzdk:9
**Response (200 OK):**
wzxhzdk:10
**MCP call example:**
wzxhzdk:11
**Source:** https://www.algolia.com/doc/rest-api/search/multiple-batch (action set), https://www.algolia.com/doc/api-reference/api-methods/batch/
multipleBatch — operations across MULTIPLE indices
**Purpose:** Same as `batch`, but each operation names its own `indexName`, so one request can touch many indices at once.
**REST:** `POST /1/indexes/*/batch` (host `https://$ALGOLIA_APP_ID.algolia.net`) ACL required: `addObject`
**MCP tool:** `mcp__algolia__multipleBatch`
**Key parameters:**
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| `applicationId` | string | yes | — | Algolia app ID (MCP only) |
| `requestBody.requests` | array | yes | — | List of `{ action, indexName, body }` operations |
| `requests[].action` | enum | yes | — | Same action set as `batch` (see table above) |
| `requests[].indexName` | string | yes | — | Index this operation applies to |
| `requests[].body` | object | no | — | Operation arguments (varies with `action`) |
**curl example:**
wzxhzdk:12
**Response (200 OK)** — note `taskID` is an object keyed by index name:
wzxhzdk:13
**MCP call example:**
wzxhzdk:14
**Source:** https://www.algolia.com/doc/rest-api/search/multiple-batch
Deleting records
deleteObject — delete one record
**Purpose:** Delete a single record by its `objectID`.
**REST:** `DELETE /1/indexes/{indexName}/{objectID}` (host `https://$ALGOLIA_APP_ID.algolia.net`) ACL required: `deleteObject`
**MCP tool:** `mcp__algolia__deleteObject`
**Key parameters:**
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| `applicationId` | string | yes | — | Algolia app ID (MCP only) |
| `indexName` | string | yes | — | Target index |
| `objectID` | string | yes | — | Record to delete (path param) |
**curl example:**
wzxhzdk:15
**Response (200 OK):**
wzxhzdk:16
**MCP call example:**
wzxhzdk:17
**Source:** https://www.algolia.com/doc/rest-api/search/delete-object
deleteBy — delete records matching a filter
**Purpose:** Delete every record that matches a filter expression. Useful for bulk cleanup without listing objectIDs. **Cannot be empty** (no "delete everything" via empty filters — use `clearObjects` for that).
> Resource-intensive. Algolia recommends `browse`-ing to collect objectIDs, then `batch`-deleting, > when the matched set is large.
**REST:** `POST /1/indexes/{indexName}/deleteByQuery` (host `https://$ALGOLIA_APP_ID.algolia.net`) ACL required: `deleteIndex`
**MCP tool:** `mcp__algolia__deleteBy`
**Key parameters** (at least one filter required):
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| `applicationId` | string | yes | — | Algolia app ID (MCP only) |
| `indexName` | string | yes | — | Target index |
| `requestBody.filters` | string | no* | — | Filter expression (`AND`/`OR`/`NOT`, ranges, facet/tag filters) |
| `requestBody.facetFilters` | array/string | no* | — | Facet-value filters |
| `requestBody.numericFilters` | array/string | no* | — | Numeric comparisons / ranges |
| `requestBody.tagFilters` | array/string | no* | — | `_tags` filters |
| `requestBody.aroundLatLng` | string | no | `""` | Center point for geo filtering (`"lat,lng"`) |
| `requestBody.aroundRadius` | int \| `"all"` | no | — | Geo radius in meters, or `"all"` |
| `requestBody.insideBoundingBox` | array | no | — | Rectangular geo area |
| `requestBody.insidePolygon` | array | no | — | Polygon geo area |
\* At least one filter must be provided — empty filters are rejected.
**curl example:**
wzxhzdk:18
**Response (200 OK):**
wzxhzdk:19
**MCP call example:**
wzxhzdk:20
**Source:** https://www.algolia.com/doc/rest-api/search/delete-by
clearObjects — delete ALL records (keep settings)
**Purpose:** Empty an index of all records while preserving its settings, synonyms, and rules.
**REST:** `POST /1/indexes/{indexName}/clear` (host `https://$ALGOLIA_APP_ID.algolia.net`) ACL required: `deleteIndex`. No request body.
**MCP tool:** `mcp__algolia__clearObjects`
**Key parameters:**
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| `applicationId` | string | yes | — | Algolia app ID (MCP only) |
| `indexName` | string | yes | — | Index to empty |
**curl example:**
wzxhzdk:21
**Response (200 OK):**
wzxhzdk:22
**MCP call example:**
wzxhzdk:23
**Source:** https://www.algolia.com/doc/rest-api/search/clear-objects
Reading records
getObject — retrieve one record
**Purpose:** Fetch a single record by `objectID`, optionally limiting which attributes come back.
**REST:** `GET /1/indexes/{indexName}/{objectID}` (host `https://$ALGOLIA_APP_ID-dsn.algolia.net` for reads) ACL required: `search` Optional query param: `attributesToRetrieve` (comma-separated list).
**MCP tool:** `mcp__algolia__getObject`
**Key parameters:**
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| `applicationId` | string | yes | — | Algolia app ID (MCP only) |
| `indexName` | string | yes | — | Source index |
| `objectID` | string | yes | — | Record to fetch (path param) |
| `attributesToRetrieve` | string[] | no | all retrievable | Limit returned attributes |
> Attributes listed in `unretrievableAttributes` only come back when the request is authenticated with admin credentials.
**curl example:**
wzxhzdk:24
**Response (200 OK):** the record object (always includes `objectID`):
wzxhzdk:25
**MCP call example:**
wzxhzdk:26
**Source:** https://www.algolia.com/doc/rest-api/search/get-object
getObjects — retrieve many records (cross-index)
**Purpose:** Fetch multiple records in one round-trip; each request line can target a different index.
**REST:** `POST /1/indexes/*/objects` (host `https://$ALGOLIA_APP_ID-dsn.algolia.net`) ACL required: `search`
**MCP tool:** `mcp__algolia__getObjects`
**Key parameters:**
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| `applicationId` | string | yes | — | Algolia app ID (MCP only) |
| `requestBody.requests` | array | yes | — | List of records to fetch |
| `requests[].objectID` | string | yes | — | Record ID |
| `requests[].indexName` | string | yes | — | Index to fetch from |
| `requests[].attributesToRetrieve` | string[] | no | all retrievable | Limit returned attributes |
**curl example:**
wzxhzdk:27
**Response (200 OK):** results in the same order as requests (missing records appear as `null`):
wzxhzdk:28
**MCP call example:**
wzxhzdk:29
**Source:** https://www.algolia.com/doc/rest-api/search/get-objects
Index management
operationIndex — copy or move an index
**Purpose:** Copy or rename (move) an index. **Move** = rename, overwriting the destination. **Copy** = duplicate records + settings + synonyms + rules into the destination (or a subset via `scope`).
**REST:** `POST /1/indexes/{indexName}/operation` (host `https://$ALGOLIA_APP_ID.algolia.net`) ACL required: `addObject`
**MCP tool:** `mcp__algolia__operationIndex`
**Key parameters:**
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| `applicationId` | string | yes | — | Algolia app ID (MCP only) |
| `indexName` | string | yes | — | **Source** index (path param) |
| `requestBody.operation` | enum | yes | — | `"move"` or `"copy"` |
| `requestBody.destination` | string | yes | — | Target index name |
| `requestBody.scope` | string[] | no | all | **Copy only.** Any of `settings`, `synonyms`, `rules`. Omit = copy everything (records + all three) |
**Behavior notes:** - **Copy** creates or overwrites the destination and merges API keys; it **cannot** copy `enableReRanking`, `mode`, or `replicas`. If `scope` is set, only those scopes are copied — records stay unchanged. - **Move** renames the index; ignored if the source doesn't exist. Analytics under the old name are retained; new analytics start under the new name.
**curl example (move):**
wzxhzdk:30
**Response (200 OK):**
wzxhzdk:31
**MCP call example (copy, settings only):**
wzxhzdk:32
**Source:** https://www.algolia.com/doc/rest-api/search/operation-index
listIndices — list all indices
**Purpose:** List every index in the application, with metadata (size, entry count, pending tasks, replica links).
**REST:** `GET /1/indexes` (host `https://$ALGOLIA_APP_ID.algolia.net`) ACL required: `listIndexes` Query params: `page` (int ≥ 0, or `null` for non-paginated), `hitsPerPage` (int, default 100).
**MCP tool:** `mcp__algolia__listIndices`
**Key parameters:**
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| `applicationId` | string | yes | — | Algolia app ID (MCP only) |
| `page` | integer | no | — | Page of the response; `null`/omit = not paginated |
| `hitsPerPage` | integer | no | `100` | Indices per page |
**curl example:**
wzxhzdk:33
**Response (200 OK):**
wzxhzdk:34
> `pendingTask` / `numberOfPendingTasks` tell you whether the index still has indexing work queued — > handy as a coarse "is everything applied?" check (see Async tasks below for the precise method).
**MCP call example:**
wzxhzdk:35
**Source:** https://www.algolia.com/doc/rest-api/search/list-indices
deleteIndex — delete an index
**Purpose:** Permanently delete an index (records + settings + synonyms + rules). Analytics data is preserved.
**REST:** `DELETE /1/indexes/{indexName}` (host `https://$ALGOLIA_APP_ID.algolia.net`) ACL required: `deleteIndex`
**MCP tool:** `mcp__algolia__deleteIndex`
**Key parameters:**
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| `applicationId` | string | yes | — | Algolia app ID (MCP only) |
| `indexName` | string | yes | — | Index to delete |
**Behavior notes:** Deleting a non-existent index is silently ignored. Deleting a primary makes its replicas independent. Replicas must be unlinked before they can be deleted.
**curl example:**
wzxhzdk:36
**Response (200 OK):**
wzxhzdk:37
**MCP call example:**
wzxhzdk:38
**Source:** https://www.algolia.com/doc/rest-api/search/delete-index