Modal Secrets API

Modal Secrets are encrypted, named bundles of environment variables injected into Functions and Sandboxes at runtime. Manage via dashboard, the `modal secret` CLI, or programmatically with `Secret.from_name()` / `Secret.from_dict()`.

OpenAPI Specification

modal-secrets-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Modal Secrets API
  description: |
    Modal Secrets — encrypted environment-variable references that are
    injected into Functions and Sandboxes at runtime. Secrets are named
    objects scoped to a workspace and environment, and are managed via
    the dashboard, the `modal secret` CLI, or the SDK.
  version: 0.1.0
  contact:
    name: Modal Labs
    url: https://modal.com
servers:
- url: https://api.modal.com/v1
tags:
- name: Secrets
  description: Encrypted environment-variable secrets.
paths:
  /secrets:
    get:
      tags:
      - Secrets
      summary: List Secrets
      operationId: listSecrets
      responses:
        '200':
          description: A page of secrets.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/Secret'
    post:
      tags:
      - Secrets
      summary: Create Secret
      operationId: createSecret
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SecretCreate'
      responses:
        '201':
          description: Secret created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Secret'
  /secrets/{secret_name}:
    get:
      tags:
      - Secrets
      summary: Get Secret
      description: Get a Secret's metadata. Values are never returned.
      operationId: getSecret
      parameters:
      - name: secret_name
        in: path
        required: true
        schema:
          type: string
      responses:
        '200':
          description: Secret metadata.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Secret'
    delete:
      tags:
      - Secrets
      summary: Delete Secret
      operationId: deleteSecret
      parameters:
      - name: secret_name
        in: path
        required: true
        schema:
          type: string
      responses:
        '204':
          description: Secret deleted.
components:
  schemas:
    Secret:
      type: object
      properties:
        secret_id:
          type: string
        name:
          type: string
        environment:
          type: string
        created_at:
          type: string
          format: date-time
        keys:
          type: array
          items:
            type: string
    SecretCreate:
      type: object
      required: [name, env]
      properties:
        name:
          type: string
        environment:
          type: string
        env:
          type: object
          additionalProperties:
            type: string
  securitySchemes:
    ModalToken:
      type: http
      scheme: bearer
security:
- ModalToken: []