docs/docs/api-reference/metadata-api/index.mdx
The Metadata API is primarily intended to be used as an admin API to manage the Hasura Metadata.
:::tip Supported from
The Metadata API is supported for versions v2.0.0 and above and replaces the older
schema/Metadata API.
:::
All requests are POST requests to the /v1/metadata endpoint.
POST /v1/metadata HTTP/1.1
{
"type": <query-type>,
"version": <Integer> (optional),
"resource_version": <Integer> (optional),
"args": <args-object>
}
The structure of args depends on the type and version.
| Key | Required | Schema | Description |
|---|---|---|---|
| type | true | String | Type of the query |
| resource_version | false | Integer | Version of the resource that you are targeting for replacement |
| args | true | JSON Value | The arguments to the query |
| version | false | Integer | Version of the API (inferred by args structure) |
The various types of queries are listed in the following table:
<div className="api-metadata-request-type-table">See:
| Status code | Description | Response structure |
|---|---|---|
| 200 | Success | Request specific |
| 400 | Bad request | { "path" : String, "error" : String} |
| 401 | Unauthorized | {"error" : String} |
| 500 | Internal server error | {"error" : String} |
Since this API can be used to make changes to the GraphQL schema, it can be disabled, especially in production deployments.
The enabled-apis flag or the HASURA_GRAPHQL_ENABLED_APIS env var can be used to enable/disable this API. By default,
the schema/Metadata API is enabled. To disable it, you need to explicitly state that this API is not enabled i.e. remove
it from the list of enabled APIs.
# enable only graphql api, disable Metadata and pgdump
--enabled-apis="graphql"
HASURA_GRAPHQL_ENABLED_APIS="graphql"
See GraphQL Engine server config reference for info on setting the above flag/env var.
Metadata is versioned with an optional resource_version field in operations and responses.
This is intended to allow for feedback when replacing Metadata with modifications to an out-of-date copy.
The resource_version supplied must match the version returned otherwise a 409 error response is returned.
The version is incremented on any operation that modified Metadata as well as reload_metadata.