openapi: 3.0.1
info:
  title: Fields
  description: >
    Manage custom fields used to store additional metadata on Canto DAM
    assets (distinct from the self-registration custom fields managed by
    the User API).
  version: 1.0.0
servers:
  - url: "https://{tenantSubdomain}.{region}/api/v1"
    variables:
      tenantSubdomain:
        default: demo
      region:
        default: canto.com
        enum:
          - canto.com
          - canto.global
          - canto.de
          - au.canto.com
          - ca.canto.com
security:
  - cantoOAuth2: []
  - bearerAuth: []
tags:
  - name: Fields
    description: Manage custom fields for asset metadata.
paths:
  /custom/field:
    get:
      tags:
        - Fields
      summary: Get custom field list
      operationId: get_v1_custom_field
      description: Returns the account's custom fields, including their type and values (if any).
      responses:
        "200":
          description: The account's custom fields.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/custom_field"
              example:
                - id: <custom-field-id>
                  name: Asset Type
                  type: MULTICHOICE
                  values: [Brochure, Photo, Lifestyle, Model, Presentation, Product]
                - id: <custom-field-id>
                  name: Product ID
                  type: TEXT
                - id: <custom-field-id>
                  name: Rating
                  type: RATING
    post:
      tags:
        - Fields
      summary: Create a custom field
      operationId: post_v1_custom_field
      description: Creates a new custom field.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [name, description, type]
              properties:
                name:
                  type: string
                  description: Must be unique. Max length 80.
                description:
                  type: string
                  description: Max length 800.
                type:
                  type: string
                  enum: [NUMBER, TEXT, DATE, SINGLECHOICE, MULTICHOICE, URL, LABEL, RATING]
                values:
                  type: array
                  description: Options for SINGLECHOICE and MULTICHOICE fields.
                  items:
                    type: string
      responses:
        "200":
          description: The custom field was created.
    put:
      tags:
        - Fields
      summary: Update a custom field
      operationId: put_v1_custom_field
      description: Updates an existing custom field.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [id, name, description]
              properties:
                id:
                  type: string
                name:
                  type: string
                  description: Must be unique. Max length 80.
                description:
                  type: string
                  description: Max length 800.
                type:
                  type: string
                  enum: [NUMBER, TEXT, DATE, SINGLECHOICE, MULTICHOICE, URL, LABEL, RATING]
                values:
                  type: array
                  description: Options for SINGLECHOICE and MULTICHOICE fields.
                  items:
                    type: string
      responses:
        "200":
          description: The custom field was updated.
  /custom/field/{id}:
    delete:
      tags:
        - Fields
      summary: Delete a custom field
      operationId: delete_v1_custom_field_id
      description: Deletes a custom field.
      parameters:
        - name: id
          in: path
          required: true
          description: The id of the custom field to delete.
          schema:
            type: string
      responses:
        "200":
          description: The custom field was deleted.
components:
  securitySchemes:
    cantoOAuth2:
      type: oauth2
      description: >
        Authorize against your own Canto account. Choose the tenant and its
        region in the portal first; the portal fills in the application
        identifier for that region and pre-fills your account name on
        Canto's sign-in page. This is a public-client PKCE flow: no client
        secret is used, and none is held by the portal.
      flows:
        authorizationCode:
          authorizationUrl: https://oauth.canto.com/oauth/api/oauth2/universal2/authorize
          tokenUrl: https://oauth.canto.com/oauth/api/oauth2/universal2/token
          scopes: {}
          x-usePkce: plain
          x-tokenName: accessToken
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: AccessToken
      description: >
        Paste a Target-API OAuth Token obtained out-of-band. Use the
        Authorize button instead to obtain one interactively.
  schemas:
    custom_field:
      type: object
      properties:
        id:
          type: string
          description: Uniquely identifies the custom field.
        name:
          type: string
          description: Uniquely names the custom field.
        type:
          type: string
          enum: [NUMBER, TEXT, DATE, SINGLECHOICE, MULTICHOICE, URL, LABEL, RATING]
        values:
          type: array
          description: Present only for SINGLECHOICE and MULTICHOICE fields.
          items:
            type: string
