v1

latestOpenAPI 3.0.12026-07-1714724311.1 KB
Relations

Create a Relation

Create a new relation.

post/relations

Query parameters

fieldsstring[]

Control what fields are being returned in the object.

metastring

What metadata to return in the response.

Request body

collection_manystring

Collection that has the field that holds the foreign key.

collection_onestring

Collection on the one side of the relationship.

field_manystring

Foreign key. Field that holds the primary key of the related collection.

field_onestring

Alias column that serves as the one side of the relationship.

junction_fieldstring

Field on the junction table that holds the primary key of the related collection.

Example request

{
  "collection_many": "articles",
  "collection_one": "authors",
  "field_many": "author",
  "field_one": "books"
}

Response

Successful request

Example response

{
  "data": {
    "id": 1,
    "many_collection": "directus_activity",
    "many_field": "user",
    "one_collection": "directus_users"
  }
}