Skip to content

Admin API: Type definition downloads

Operations that get the OpenAPI, TypeScript types, GraphQL schema, and schema file generated from the content types of a space. Common rules (authentication, error format, dates and times) are in the Admin API reference.

In the examples, replace <hostname> with the hostname of your environment and <access token> with an access token that starts with hako_pat_. Replace other values in angle brackets, such as <slug>, with the values described in each operation’s parameter table.

Operation Method and path
Download the GraphQL schema (SDL) GET /admin/api/spaces/{slug}/schema/graphql
Download the schema file (*.hako.json) GET /admin/api/spaces/{slug}/schema/hako.json
Download the OpenAPI for the public API (with types for each content type) GET /admin/api/spaces/{slug}/schema/openapi.json
Download TypeScript types for entries GET /admin/api/spaces/{slug}/schema/types.ts

The GraphQL schema of the public API. Get it again after you change the schema.

GET /admin/api/spaces/{slug}/schema/graphql
  • Login: required (session or access token)

Parameters:

Name In Type Required Constraints Description
slug path string Yes Slug of the space

Responses:

Status Body Reason
200 File (text/plain)
401 Error (application/json) Not logged in, or the access token is wrong, expired, or revoked
404 Error (application/json) Not found. A space you are not a member of also returns 404

If the request fails, you get a 4xx or 5xx status and a JSON body with message. The meaning of each status is in the list of errors.

Example:

ターミナルウィンドウ
curl "https://<hostname>.hakocms.net/admin/api/spaces/<slug>/schema/graphql" \
-H "Authorization: Bearer <access token>"

Returns the current schema in a form you can pass as is to schema apply (schema apply).

GET /admin/api/spaces/{slug}/schema/hako.json
  • Login: required (session or access token)

Parameters:

Name In Type Required Constraints Description
slug path string Yes Slug of the space

Responses:

Status Body Reason
200 Object (application/json)
401 Error (application/json) Not logged in, or the access token is wrong, expired, or revoked
404 Error (application/json) Not found. A space you are not a member of also returns 404

If the request fails, you get a 4xx or 5xx status and a JSON body with message. The meaning of each status is in the list of errors.

Example:

ターミナルウィンドウ
curl "https://<hostname>.hakocms.net/admin/api/spaces/<slug>/schema/hako.json" \
-H "Authorization: Bearer <access token>"

Download the OpenAPI for the public API (with types for each content type)

Section titled “Download the OpenAPI for the public API (with types for each content type)”

The OpenAPI 3.1 of the public API (Content API). Get it again after you change the schema.

GET /admin/api/spaces/{slug}/schema/openapi.json
  • Login: required (session or access token)

Parameters:

Name In Type Required Constraints Description
slug path string Yes Slug of the space

Responses:

Status Body Reason
200 Object (application/json)
401 Error (application/json) Not logged in, or the access token is wrong, expired, or revoked
404 Error (application/json) Not found. A space you are not a member of also returns 404

If the request fails, you get a 4xx or 5xx status and a JSON body with message. The meaning of each status is in the list of errors.

Example:

ターミナルウィンドウ
curl "https://<hostname>.hakocms.net/admin/api/spaces/<slug>/schema/openapi.json" \
-H "Authorization: Bearer <access token>"

The shape of entries you read with the public API. Get it again after you change the schema.

GET /admin/api/spaces/{slug}/schema/types.ts
  • Login: required (session or access token)

Parameters:

Name In Type Required Constraints Description
slug path string Yes Slug of the space

Responses:

Status Body Reason
200 File (application/typescript)
401 Error (application/json) Not logged in, or the access token is wrong, expired, or revoked
404 Error (application/json) Not found. A space you are not a member of also returns 404

If the request fails, you get a 4xx or 5xx status and a JSON body with message. The meaning of each status is in the list of errors.

Example:

ターミナルウィンドウ
curl "https://<hostname>.hakocms.net/admin/api/spaces/<slug>/schema/types.ts" \
-H "Authorization: Bearer <access token>"