Get Message Metadata Keys
Overview
Discover the custom metadata keys (and sample values) currently stored on messages in the tenant workspace.
Use the returned keys to build filter UIs for metadata.<key> query parameters on List Messages. Each entry includes how often the key appears, how many distinct values exist, and example values.
When to use this endpoint?
Use Get Message Metadata Keys when:
- Building admin filters that query
metadata.<key>=valueon List Messages. - You need to know which metadata keys exist before hard-coding filter fields.
- Showing facet counts or sample values in a moderation or analytics UI.
- Auditing which custom fields your app has attached to messages.
GET
{baseUrl}/api/{apiVersion}/client/messages/metadata-keys- Authentication
- Required (Bearer token)
- Tenant-scoped
- Yes (tenant DB - requires x-client-id)
Request Headers
Success Response (HTTP 200 OK)
On success, the API returns the metadata keys found on messages, with counts and sample values.
json
{ "success": true, "message": "Metadata keys fetched successfully", "data": { "keys": [ { "key": "workspaceId", "count": 128, "totalValues": 3, "values": [ "c1", "c2", "c3" ] }, { "key": "flagged", "count": 6, "totalValues": 2, "values": [ false, true ] } ] }, "error": null}Common Errors
HTTP 200 OK means the keys were fetched successfully. Requests fail when tenant headers or authentication are missing or invalid.
Best Practices
- Call this endpoint when building filter UIs so you only offer keys that actually exist.
- Map each returned
keyto ametadata.<key>query param on List Messages. - Use
valuesas suggestions for dropdowns, but allow free text when new values appear. - Re-fetch keys after bulk metadata updates so filter options stay current.
- Always send
is-tenant: trueand a validx-client-idwith a Bearer token.
Ready to filter by metadata
Use the returned keys with List Messages query params such as metadata.workspaceId=c1 to narrow results in your admin UI.