Type Definitions

How to generate static types based on our data schema

At this time, we do not provide a first-class type definition library for the API. If you require strict typings when working with API responses, you can use one of the following approaches.

Option 1: Create Custom Type Definitions

Define your own types based on the expected API responses. This approach gives you full control over:

  • Naming conventions

  • Optional vs. required fields

  • Nested object structures

  • Field transformations applied in your application

Use the API responses and schema definitions as the source of truth when modeling your types.

Recommended when:
You need clean, maintainable, and project-specific typings.

Option 2: Use the Code Snippets Repository

Copy and paste the type schema from our code snippets repository. We maintain and update these definitions regularly to reflect changes in the API schema.

Recommended when:
You want a quick starting point with minimal setup.

Beware that:

You might not have access to all data types that have an interface is this type schema. What data you can access depends on your permissions.

Option 3: Generate Types from the OpenAPI Specification

You can generate types automatically from our OpenAPI specification using standard OpenAPI tooling.

However, be aware that:

  • The generated types may be verbose.

  • The structure may not be idiomatic for your language.

  • Some definitions may be difficult to use directly.

This is due to how Directus generates its OpenAPI specification, which prioritizes completeness over developer ergonomics.

Recommended when:
You need automated synchronization with the API schema and are comfortable refining the generated output.