> ## Documentation Index
> Fetch the complete documentation index at: https://docs.poly.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a secret

> Create a secret for the account this agent belongs to. Use for credentials the agent needs at runtime. Secrets are scoped to the account/workspace, not the individual agent.

## Scoping

<Note>
  Secrets belong to the **account (workspace)** that owns this agent, not the agent itself. Any other agent in the same account can be granted access to the same secret. The `agentId` in the path only determines which account the secret is created under and which agent gets initial access; it does not scope lookups.
</Note>

<Warning>
  PolyAI does not enforce an expiry on secrets. If you need to rotate credentials on a schedule (e.g. an annual refresh policy), call [Update a secret](/api-reference/agents/endpoint/secrets/update-a-secret); PolyAI does not track or enforce rotation cadence itself.
</Warning>


## OpenAPI

````yaml POST /v1/agents/{agentId}/secrets
openapi: 3.1.0
info:
  title: PolyAI Agents API
  version: 1.0.11
  description: Manage PolyAI agents, telephony, deployments, and real-time configs.
servers:
  - url: https://api.us.poly.ai
    description: US region
  - url: https://api.eu.poly.ai
    description: EU region
  - url: https://api.uk.poly.ai
    description: UK region
  - url: https://api.studio.poly.ai
    description: Studio region
security:
  - polyApiKey: []
paths:
  /v1/agents/{agentId}/secrets:
    parameters:
      - name: agentId
        in: path
        required: true
        schema:
          type: string
    post:
      tags:
        - Secrets
      summary: Create a secret
      description: >-
        Create a secret for the account this agent belongs to. Use for
        credentials the agent needs at runtime. Secrets are scoped to the
        account/workspace, not the individual agent.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateSecretBody'
      responses:
        '201':
          description: Created secret
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SecretResponse'
components:
  schemas:
    CreateSecretBody:
      type: object
      properties:
        name:
          type: string
          minLength: 1
          description: Display name of the secret
        value:
          type: string
          minLength: 1
          description: Secret value
        description:
          type: string
          description: Description of the secret
      required:
        - name
        - value
      additionalProperties: false
      title: CreateSecretBody
    SecretResponse:
      type: object
      properties:
        name:
          type: string
          description: Display name of the secret
        description:
          type: string
          description: Description of the secret
        createdAt:
          type: string
          description: ISO 8601 timestamp of creation
        lastUpdated:
          description: ISO 8601 timestamp of last update
          type: string
      required:
        - name
      additionalProperties: false
      title: SecretResponse
  securitySchemes:
    polyApiKey:
      type: apiKey
      in: header
      name: X-API-KEY

````