Azure Cosmos DB Collections API

Document collections (containers)

OpenAPI Specification

azure-cosmos-db-collections-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Azure Cosmos DB Data Plane REST Collections API
  version: '2018-12-31'
  description: 'Data-plane REST API for Azure Cosmos DB (SQL/Core API). Requests are sent to the

    per-account endpoint `https://{databaseaccount}.documents.azure.com` and authorized

    with a master key or resource token using HMAC-signed `Authorization` headers, or

    with a Microsoft Entra ID bearer token. The `x-ms-version` header selects the API

    version; the latest known version is used when omitted.

    '
  contact:
    name: Azure Cosmos DB REST API
    url: https://learn.microsoft.com/en-us/rest/api/cosmos-db/
servers:
- url: https://{databaseaccount}.documents.azure.com
  description: Cosmos DB account endpoint
  variables:
    databaseaccount:
      default: my-account
      description: Your Cosmos DB account name
tags:
- name: Collections
  description: Document collections (containers)
paths:
  /dbs/{dbId}/colls:
    parameters:
    - in: path
      name: dbId
      required: true
      schema:
        type: string
    get:
      summary: List collections in a database
      operationId: listCollections
      tags:
      - Collections
      responses:
        '200':
          description: Collections
          content:
            application/json:
              schema:
                type: object
                properties:
                  DocumentCollections:
                    type: array
                    items:
                      type: object
      security:
      - cosmosAuth: []
      - entra: []
    post:
      summary: Create a collection
      operationId: createCollection
      tags:
      - Collections
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - id
              properties:
                id:
                  type: string
                partitionKey:
                  type: object
                indexingPolicy:
                  type: object
      responses:
        '201':
          description: Collection created
          content:
            application/json:
              schema:
                type: object
      security:
      - cosmosAuth: []
      - entra: []
  /dbs/{dbId}/colls/{collId}:
    parameters:
    - in: path
      name: dbId
      required: true
      schema:
        type: string
    - in: path
      name: collId
      required: true
      schema:
        type: string
    get:
      summary: Get a collection
      operationId: getCollection
      tags:
      - Collections
      responses:
        '200':
          description: Collection
          content:
            application/json:
              schema:
                type: object
      security:
      - cosmosAuth: []
      - entra: []
    delete:
      summary: Delete a collection
      operationId: deleteCollection
      tags:
      - Collections
      responses:
        '204':
          description: Deleted
      security:
      - cosmosAuth: []
      - entra: []
components:
  securitySchemes:
    cosmosAuth:
      type: apiKey
      in: header
      name: Authorization
      description: 'Cosmos DB master-key or resource-token HMAC signature. Format:

        `type=master&ver=1.0&sig=<base64-hmac-sha256>` (URL-encoded).

        See https://learn.microsoft.com/en-us/rest/api/cosmos-db/access-control-on-cosmosdb-resources

        '
    entra:
      type: oauth2
      description: Microsoft Entra ID OAuth 2.0 bearer token
      flows:
        clientCredentials:
          tokenUrl: https://login.microsoftonline.com/common/oauth2/v2.0/token
          scopes:
            https://cosmos.azure.com/.default: Cosmos DB data plane access