openapi: 3.0.2
info:
  title: Strapi Content Manager API
  version: 1.0.0
servers:
  - url: http://localhost:1337
    description: Local server
externalDocs:
  url: https://docs.strapi.io
  description: Strapi documentation
paths:
  /content-manager/content-types:
    get:
      tags:
        - ContentTypes
      description: List content types
      parameters:
        - $ref: '#/components/parameters/kind'
      responses:
        200:
          description: A list of content types
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/contentType'
  /content-manager/content-types-settings:
    get:
      tags:
        - ContentTypes
      description: List content types settings
      responses:
        200:
          description: A list of content types settings
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/contentTypeSettings'
  /content-manager/content-types/{uid}/configuration:
    get:
      tags:
        - ContentTypes
      description: Get content type configuration
      parameters:
        - $ref: '#/components/parameters/uid'
      responses:
        200:
          description: A content type configuration with its components configuration
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      contentType:
                        $ref: '#/components/schemas/content-type-configuration'
                      components:
                        type: object
                        additionalProperties:
                          $ref: '#/components/schemas/component-configuration'
    put:
      tags:
        - ContentTypes
      description: Edit content type configuration
      parameters:
        - $ref: '#/components/parameters/uid'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/configuration'
      responses:
        200:
          description: A content type configuration
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/content-type-configuration'
  /content-manager/components:
    get:
      tags:
        - Components
      description: List components
      responses:
        200:
          description: A list of components
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/component'
  /content-manager/components/{uid}/configuration:
    get:
      tags:
        - Components
      description: Get content type configuration
      parameters:
        - $ref: '#/components/parameters/uid'
      responses:
        200:
          description: A component configuration with its components configuration
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      component:
                        $ref: '#/components/schemas/component-configuration'
                      components:
                        type: object
                        additionalProperties:
                          $ref: '#/components/schemas/component-configuration'
    put:
      tags:
        - Components
      description: Edit component configuration
      parameters:
        - $ref: '#/components/parameters/uid'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/configuration'
      responses:
        200:
          description: A component configuration with its components configuration
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/component-configuration'
  # UID
  /content-manager/uid/generate:
    post:
      tags:
        - UID attribute utils
      description: Generate a uid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - contentTypeUID
                - field
                - data
              properties:
                contentTypeUID:
                  type: string
                field:
                  type: string
                data:
                  type: object
                  description: Current value of the entry being created or edited
      responses:
        200:
          description: A generated uid value
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: string
  /content-manager/uid/check-availability:
    post:
      tags:
        - UID attribute utils
      description: Check availability of a uid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - contentTypeUID
                - field
                - value
              properties:
                contentTypeUID:
                  type: string
                field:
                  type: string
                value:
                  type: string
      responses:
        200:
          description: A generated uid value
          content:
            application/json:
              schema:
                type: object
                required:
                  - isAvailable
                properties:
                  isAvailable:
                    type: boolean
                  suggestion:
                    type: string
                    description: Suggestion if request value is not available
  # Relationships
  /content-manager/relations/{model}/{targetField}:
    post:
      tags:
        - Relational fields
      description: Get available entries to add to a relational field
      parameters:
        - in: path
          name: model
          schema:
            type: string
          required: true
          description: Content type uid or component uid depending on what holds the relation
        - in: path
          name: targetField
          schema:
            type: string
          required: true
          description: Name of the field in the model that holds the relation
        - in: query
          name: entityId
          schema:
            type: string
          description: Id of the entry or the component, used to omit already existing relations (if the entity already exists)
        - in: query
          name: idsToOmit
          schema:
            type: array
            items:
              type: string
              name: id
          description: Used to omit ids of client-side selected relations (for entities that haven’t been created in the DB yet)
        - in: query
          name: idsToInclude
          schema:
            type: array
            items:
              type: string
              name: id
          description: Used to include ids of client-side unselected relations (for entities that haven’t been removed from the DB yet)
        - in: query
          name: _q
          schema:
            type: string
          description: Search among the available relations (against the main field only)
        - in: query
          name: page
          schema:
            type: integer
          description: Page number to fetch
        - in: query
          name: pageSize
          schema:
            type: integer
          description: Page size to fetch

      responses:
        200:
          description: Returns a list of sanitized entries based of the relational attribute info
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  properties:
                    results:
                      type: array
                      items:
                        type: object
                        properties:
                          id:
                            $ref: '#/components/schemas/id'
                          '[mainField]':
                            type: string
                            description: Value of the mainField of the entry
                          publishedAt:
                            type: date
                    pagination:
                      $ref: '#/components/schemas/pagination'

  /content-manager/relations/{model}/{id}/{targetField}:
    post:
      tags:
        - Relational fields
      description: Get existing entries for a relational field of an entry
      parameters:
        - in: path
          name: model
          schema:
            type: string
          required: true
          description: Content type uid or component uid depending on what holds the relation
        - in: path
          name: id
          schema:
            type: string
          required: true
          description: Id of the entity (entry or component) that holds the relation
        - in: path
          name: targetField
          schema:
            type: string
          required: true
          description: Name of the field in the model that holds the relation
        - in: query
          name: page
          schema:
            type: integer
          description: Page number to fetch
        - in: query
          name: pageSize
          schema:
            type: integer
          description: Page size to fetch

      responses:
        200:
          description: Returns a list of sanitized entries based of the relational attribute info
          content:
            application/json:
              schema:
                type: array
                items:
                  oneOf:
                    - type: object
                      properties:
                        results:
                          type: array
                          items:
                            type: object
                            properties:
                              id:
                                $ref: '#/components/schemas/id'
                              '[mainField]':
                                type: string
                                description: Value of the mainField of the entry
                              publishedAt:
                                type: date
                        pagination:
                          $ref: '#/components/schemas/pagination'
                    - type: object
                      properties:
                        data:
                          type: object
                          properties:
                            id:
                              $ref: '#/components/schemas/id'
                            '[mainField]':
                              type: string
                              description: Value of the mainField of the entry
                            publishedAt:
                              type: date

  # Collection type
  /content-manager/collection-types/{model}:
    get:
      tags:
        - Collection Types content management
      description: |
        Get a list of entries

        All components and dynamic zones along with relations (1 level only) are automatically populated.

        xToMany relations are counted (exemple: { count: 4 }).
      parameters:
        - $ref: '#/components/parameters/model'
      responses:
        200:
          content:
            application/json:
              schema:
                type: object
                properties:
                  results:
                    type: array
                    items:
                      $ref: '#/components/schemas/entity'
                  pagination:
                    $ref: '#/components/schemas/pagination'
    post:
      tags:
        - Collection Types content management
      description: Create an entry
      parameters:
        - $ref: '#/components/parameters/model'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/entityInput'
      responses:
        200:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/entity'
  /content-manager/collection-types/{model}/actions/bulkDelete:
    post:
      tags:
        - Collection Types content management
      description: Bulk delete entries
      parameters:
        - $ref: '#/components/parameters/model'
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                ids:
                  type: array
                  items:
                    $ref: '#/components/schemas/id'
      responses:
        200:
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/entity'
  /content-manager/collection-types/{model}/{id}:
    get:
      tags:
        - Collection Types content management
      description: |
        Get one entry

        All components and dynamic zones along with relations (1 level only) are automatically populated.

        All relations are counted (exemple: { count: 4 }).
      parameters:
        - $ref: '#/components/parameters/model'
        - $ref: '#/components/parameters/entity-id'
      responses:
        200:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/entity'
    put:
      tags:
        - Collection Types content management
      description: Update one entry
      parameters:
        - $ref: '#/components/parameters/model'
        - $ref: '#/components/parameters/entity-id'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/entityInput'
      responses:
        200:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/entity'
    delete:
      tags:
        - Collection Types content management
      description: Delete one entry
      parameters:
        - $ref: '#/components/parameters/model'
        - $ref: '#/components/parameters/entity-id'
      responses:
        200:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/entity'
  /content-manager/collection-types/{model}/{id}/actions/publish:
    post:
      tags:
        - Collection Types content management
      description: Publish one entry
      parameters:
        - $ref: '#/components/parameters/model'
        - $ref: '#/components/parameters/entity-id'
      responses:
        200:
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/entity'
                  - type: object
                    properties:
                      publishedAt:
                        type: datetime
  /content-manager/collection-types/{model}/{id}/actions/unpublish:
    post:
      tags:
        - Collection Types content management
      description: Unpublish one entry
      parameters:
        - $ref: '#/components/parameters/model'
        - $ref: '#/components/parameters/entity-id'
      responses:
        200:
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/entity'
                  - type: object
                    properties:
                      publishedAt:
                        type: datetime
  /content-manager/collection-types/{model}/{id}/actions/countDraftRelations:
    get:
      tags:
        - Collection Types content management
      description: Get the number of relations of that entry that are in draft
      parameters:
        - $ref: '#/components/parameters/model'
        - $ref: '#/components/parameters/entity-id'
      responses:
        200:
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: integer
  # Single type
  /content-manager/single-types/{model}:
    get:
      tags:
        - Single Types content management
      description: Find Single type content
      parameters:
        - $ref: '#/components/parameters/model'
      responses:
        200:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/entity'
    put:
      tags:
        - Single Types content management
      description: Update Single type content
      parameters:
        - $ref: '#/components/parameters/model'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/entityInput'
      responses:
        200:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/entity'
    delete:
      tags:
        - Single Types content management
      description: Delete Single type content
      parameters:
        - $ref: '#/components/parameters/model'
      responses:
        200:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/entity'
  /content-manager/single-types/{model}/actions/publish:
    post:
      tags:
        - Single Types content management
      description: Publish Single type content
      parameters:
        - $ref: '#/components/parameters/model'
      responses:
        200:
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/entity'
                  - type: object
                    properties:
                      publishedAt:
                        type: datetime
  /content-manager/single-types/{model}/actions/unpublish:
    post:
      tags:
        - Single Types content management
      description: Unpublish Single type content
      parameters:
        - $ref: '#/components/parameters/model'
      responses:
        200:
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/entity'
                  - type: object
                    properties:
                      publishedAt:
                        type: datetime
                        nullable: true
  /content-manager/single-types/{model}/actions/countDraftRelations:
    get:
      tags:
        - Single Types content management
      description: Get the number of relations of that entry that are in draft
      parameters:
        - $ref: '#/components/parameters/model'
      responses:
        200:
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: integer

components:
  schemas:
    id:
      oneOf:
        - type: integer
        - type: string

    pagination:
      type: object
      properties:
        page:
          type: integer
        pageSize:
          type: integer
        pageCount:
          type: integer
        total:
          type: integer

    entity:
      type: object
      required:
        - id
        - createdBy
        - updatedBy
      properties:
        id:
          $ref: '#/components/schemas/id'
        createdBy:
          $ref: '#/components/schemas/user'
        updatedBy:
          $ref: '#/components/schemas/user'
      additionalProperties:
        type: any

    entityInput:
      type: object
      additionalProperties:
        type: any

    contentTypeSettings:
      type: object
      properties:
        uid:
          type: string
          description: Model uid
        settings:
          $ref: '#/components/schemas/configurationSettings'

    contentType:
      type: object
      properties:
        uid:
          type: string
          description: Model uid
        kind:
          $ref: '#/components/schemas/kind'
        isDisplayed:
          type: boolean
        apiID:
          type: string
          description: Model key based on filename
        info:
          type: object
          properties:
            name:
              type: string
              description: User defined name
            label:
              type: string
              description: Computed label with pluralization
            description:
              type: string
              description: Content type description

        options:
          type: object
          properties:
            increments:
              type: boolean
            timestamps:
              type: array
              uniqueItems: true
              minItems: 2
              maxItems: 2
              items:
                type: string
            draftAndPublish:
              type: boolean
        attributes:
          type: object
          additionalProperties:
            oneOf:
              - $ref: '#/components/schemas/scalarAttribute'
              - $ref: '#/components/schemas/relationalAttribute'

    component:
      allOf:
        - type: object
          properties:
            category:
              type: string
              description: Component category

        - $ref: '#/components/schemas/contentType'

    scalarAttribute:
      type: object
      properties:
        type:
          type: string
        required:
          type: boolean

    relationalAttribute:
      type: object
      properties:
        type:
          type: string

        targetModel:
          type: string
        relationType:
          type: string
          enum:
            - oneWay
            - manyWay
            - oneToOne
            - oneToMany
            - manyToOne
            - manyToMany

    configurationSettings:
      type: object
      properties:
        searchable:
          type: boolean
        bulkable:
          type: boolean
        filterable:
          type: boolean
        pageSize:
          type: integer
        mainField:
          type: string
        defaultSortBy:
          type: string
        defaultSortOrder:
          type: string

    configuration:
      type: object
      properties:
        settings:
          $ref: '#/components/schemas/configurationSettings'
        metadatas:
          type: object
        layouts:
          type: object
          properties:
            list:
              type: array
              items:
                type: string
            edit:
              type: array
              items:
                type: array
                items:
                  type: object
                  properties:
                    name: string
                    size: integer

    content-type-configuration:
      allOf:
        - type: object
          properties:
            uid:
              type: string
        - $ref: '#/components/schemas/configuration'

    component-configuration:
      allOf:
        - type: object
          properties:
            isComponent:
              type: boolean
        - $ref: '#/components/schemas/content-type-configuration'

    kind:
      type: string
      enum:
        - singleType
        - collectionType

    user:
      type: object
      properties:
        id:
          oneOf:
            - type: integer
            - type: string
        firstname:
          type: string
        lastname:
          type: string
        email:
          type: string

  parameters:
    kind:
      in: query
      name: kind
      schema:
        $ref: '#/components/schemas/kind'
      description: A content type kind (singleType or collectionType)

    model:
      in: path
      name: model
      schema:
        type: string
      required: true
      description: Model uid

    uid:
      in: path
      name: uid
      schema:
        type: string
      required: true
      description: Model uid

    entity-id:
      in: path
      name: id
      schema:
        type: string
      required: true
      description: Entity id

  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

security:
  - bearerAuth: []
