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: Fetch list of possible related content
      parameters:
        - $ref: '#/components/parameters/model'
        - in: path
          name: targetField
          schema:
            type: string
          required: true
          description: Name of the field in the model that holds the relation
        - in: query
          name: _component
          schema:
            type: string
          description: Component uid if the targetField is in a component
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                idsToOmit:
                  type: array
                  items:
                    $ref: '#/components/schemas/id'
      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:
                    id:
                      $ref: '#/components/schemas/id'
                    '[primaryKey]':
                      oneOf:
                        - type: string
                        - type: integer
                    '[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
      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
      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
  # 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

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

    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
            editRelations:
              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: []
