Indexing Metadata
Once a schema is defined for a metadata group, you can attach metadata values to individual documents.
Endpoints
| Method | Path | Purpose |
|---|---|---|
PUT | /document/{docId}/custom-metadata/{groupName} | Add or replace all metadata for a (docId, groupName) pair |
DELETE | /document/{docId}/custom-metadata/{groupName} | Remove all metadata for a (docId, groupName) pair |
docId is the unique Glean identifier of the document. You can obtain it via the Client API (for example, Search or Get Documents).
Add or update metadata
PUT /document/{docId}/custom-metadata/{groupName}
Indexes custom metadata for the specified document and group.
This call replaces all metadata for the (docId, groupName) pair. Any keys not present in the request are removed from the group on that document. To update a single key without losing others, include the full set of keys in the request body.
Request body
{
"customMetadata": [
{
"name": "string",
"value": "string" | ["string", ...]
}
]
}
value is a string for TEXT and PICKLIST keys, and an array of strings for TEXTLIST and MULTIPICKLIST keys.
Example
- curl
curl -X PUT https://customer-be.glean.com/rest/api/index/document/gdrive_abc123/custom-metadata/compliance \
-H 'Authorization: Bearer <token>' \
-H 'Content-Type: application/json' \
-d '{
"customMetadata": [
{ "name": "status", "value": "Approved" },
{ "name": "reviewDate", "value": "2026-03-15" },
{ "name": "tags", "value": ["SOC2", "annual-review"] }
]
}'
Remove metadata
DELETE /document/{docId}/custom-metadata/{groupName}
Removes all metadata for the specified group from the document. Metadata for other groups on the same document is unaffected.
Rate limits
| Limit | Value |
|---|---|
| Sustained rate | 5 requests per second per group |
| Burst | Up to 300 requests |
Rate limits are enforced per metadata group, not per document. Distributing writes across multiple groups increases overall throughput.
When the limit is exceeded, the API returns 429 Too Many Requests. See Error responses for the full list of status codes.