Backblaze Application Keys API

Create and manage application keys for access control

OpenAPI Specification

backblaze-application-keys-api-openapi.yml Raw ↑
openapi: 3.0.3
info:
  title: Backblaze B2 Native Application Keys API
  description: The Backblaze B2 Native API provides programmatic access to Backblaze B2 Cloud Storage. It covers account authorization, bucket management, file upload and download, lifecycle rules, application key management, large file handling, replication, and event notifications. The API uses HTTPS with JSON request and response bodies. Authentication is performed via the b2_authorize_account endpoint which returns an authorization token used for subsequent calls.
  version: v4
  x-generated-from: documentation
  contact:
    name: Backblaze Developer Support
    url: https://www.backblaze.com/docs
  license:
    name: Proprietary
    url: https://www.backblaze.com/company/terms-of-service
servers:
- url: https://api.backblazeb2.com
  description: Backblaze B2 API (cluster-specific URL returned by b2_authorize_account)
security:
- ApplicationKeyAuth: []
tags:
- name: Application Keys
  description: Create and manage application keys for access control
paths:
  /b2api/v4/b2_create_key:
    post:
      operationId: createKey
      summary: Backblaze B2 Native API Create Key
      description: Creates a new application key. The key returned by this API can only be used to access the account that created it.
      tags:
      - Application Keys
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateKeyRequest'
            examples:
              CreateKeyRequestExample:
                summary: Default createKey request
                x-microcks-default: true
                value:
                  accountId: abc123def456
                  capabilities:
                  - listFiles
                  - readFiles
                  - writeFiles
                  keyName: my-app-key
      responses:
        '200':
          description: Application key created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApplicationKey'
              examples:
                CreateKey200Example:
                  summary: Default createKey 200 response
                  x-microcks-default: true
                  value:
                    keyName: my-app-key
                    applicationKeyId: 0014a98f9d9e8d0000000001
                    applicationKey: K0014a98f9d9e8d0000000001a9b2c3d4
                    accountId: abc123def456
                    capabilities:
                    - listFiles
                    - readFiles
                    - writeFiles
                    expirationTimestamp: null
                    bucketId: null
                    namePrefix: null
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
  /b2api/v4/b2_delete_key:
    post:
      operationId: deleteKey
      summary: Backblaze B2 Native API Delete Key
      description: Deletes the application key specified.
      tags:
      - Application Keys
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DeleteKeyRequest'
            examples:
              DeleteKeyRequestExample:
                summary: Default deleteKey request
                x-microcks-default: true
                value:
                  applicationKeyId: 0014a98f9d9e8d0000000001
      responses:
        '200':
          description: Key deleted
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApplicationKey'
              examples:
                DeleteKey200Example:
                  summary: Default deleteKey 200 response
                  x-microcks-default: true
                  value:
                    keyName: my-app-key
                    applicationKeyId: 0014a98f9d9e8d0000000001
                    accountId: abc123def456
                    capabilities:
                    - listFiles
                    - readFiles
                    - writeFiles
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
  /b2api/v4/b2_list_keys:
    post:
      operationId: listKeys
      summary: Backblaze B2 Native API List Keys
      description: Lists application keys associated with an account.
      tags:
      - Application Keys
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ListKeysRequest'
            examples:
              ListKeysRequestExample:
                summary: Default listKeys request
                x-microcks-default: true
                value:
                  accountId: abc123def456
      responses:
        '200':
          description: List of application keys
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ListKeysResponse'
              examples:
                ListKeys200Example:
                  summary: Default listKeys 200 response
                  x-microcks-default: true
                  value:
                    keys:
                    - keyName: my-app-key
                      applicationKeyId: 0014a98f9d9e8d0000000001
                      accountId: abc123def456
                      capabilities:
                      - listFiles
                      - readFiles
                      - writeFiles
                    nextApplicationKeyId: null
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
components:
  schemas:
    ErrorResponse:
      title: ErrorResponse
      type: object
      description: Standard B2 error response
      properties:
        status:
          type: integer
          description: HTTP status code
          example: 401
        code:
          type: string
          description: A single-identifier code that identifies the error
          example: unauthorized
        message:
          type: string
          description: A human-readable message describing the error
          example: Authorization token not valid
    DeleteKeyRequest:
      title: DeleteKeyRequest
      type: object
      required:
      - applicationKeyId
      properties:
        applicationKeyId:
          type: string
          description: The ID of the key to delete
          example: 0014a98f9d9e8d0000000001
    ListKeysRequest:
      title: ListKeysRequest
      type: object
      required:
      - accountId
      properties:
        accountId:
          type: string
          example: abc123def456
        maxKeyCount:
          type: integer
          description: Maximum number of keys to return
        startApplicationKeyId:
          type: string
          description: Start listing from this key ID
    ApplicationKey:
      title: ApplicationKey
      type: object
      description: A Backblaze B2 application key
      properties:
        keyName:
          type: string
          description: A name for this key
          example: my-app-key
        applicationKeyId:
          type: string
          description: The ID of the newly created key
          example: 0014a98f9d9e8d0000000001
        applicationKey:
          type: string
          description: The secret key - only returned at creation time
          example: K0014a98f9d9e8d0000000001a9b2c3d4
        accountId:
          type: string
          description: The account this key is associated with
          example: abc123def456
        capabilities:
          type: array
          items:
            type: string
          description: A list of capabilities this key has
        expirationTimestamp:
          type: integer
          nullable: true
          description: When this key expires, or null for no expiration
        bucketId:
          type: string
          nullable: true
          description: Restrict key to this bucket, or null for all buckets
        namePrefix:
          type: string
          nullable: true
          description: Restrict key to file names starting with this prefix
    CreateKeyRequest:
      title: CreateKeyRequest
      type: object
      required:
      - accountId
      - capabilities
      - keyName
      properties:
        accountId:
          type: string
          example: abc123def456
        capabilities:
          type: array
          items:
            type: string
          description: List of capabilities for the key
        keyName:
          type: string
          description: A name for the key (letters, numbers, hyphens)
          example: my-app-key
        validDurationInSeconds:
          type: integer
          description: Duration before key expires
        bucketId:
          type: string
          description: Restrict key to this bucket
        namePrefix:
          type: string
          description: Restrict key to files with this prefix
    ListKeysResponse:
      title: ListKeysResponse
      type: object
      properties:
        keys:
          type: array
          items:
            $ref: '#/components/schemas/ApplicationKey'
        nextApplicationKeyId:
          type: string
          nullable: true
  securitySchemes:
    ApplicationKeyAuth:
      type: http
      scheme: bearer
      description: Authorization token obtained from b2_authorize_account
    BasicAuth:
      type: http
      scheme: basic
      description: HTTP Basic auth using applicationKeyId as username and applicationKey as password