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

# Upsert a secret

> Creates or updates a secret by name. Scoped to the caller's primary team — use the team-scoped variant to target a specific team.



## OpenAPI

````yaml post /v1/secrets
openapi: 3.1.0
info:
  description: REST API for management of Baseten resources
  title: Baseten management API
  version: 1.0.0
servers:
  - url: https://api.baseten.co
security:
  - ApiKeyAuth: []
paths:
  /v1/secrets:
    post:
      summary: Upserts a secret
      description: >-
        Creates or updates a secret by name. Scoped to the caller's primary team
        — use the team-scoped variant to target a specific team.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpsertSecretRequestV1'
        required: true
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SecretV1'
      x-codeSamples:
        - lang: bash
          source: |-
            curl --request POST \
            --url https://api.baseten.co/v1/secrets \
            --header "Authorization: Api-Key $BASETEN_API_KEY" \
            --data '{
              "name": "my_secret",
              "value": "my_secret_value"
            }'
        - lang: python
          source: |-
            import requests
            import os
            API_KEY = os.environ.get("BASETEN_API_KEY", "<YOUR_API_KEY>")
            url = "https://api.baseten.co/v1/secrets"

            headers = {"Authorization": f"Api-Key {API_KEY}"}

            response = requests.request(
                "POST",
                url,
                headers=headers,
                json={'name': 'my_secret', 'value': 'my_secret_value'}
            )

            print(response.text)
components:
  schemas:
    UpsertSecretRequestV1:
      description: A request to create or update a Baseten secret by name.
      properties:
        name:
          description: Name of the new or existing secret
          examples:
            - my_secret
          title: Name
          type: string
        value:
          description: Value of the secret
          examples:
            - my_secret_value
          title: Value
          type: string
      required:
        - name
        - value
      title: UpsertSecretRequestV1
      type: object
    SecretV1:
      description: A Baseten secret. Note that we do not support retrieving secret values.
      properties:
        created_at:
          description: Time the secret was created in ISO 8601 format
          format: date-time
          title: Created At
          type: string
        name:
          description: Name of the secret
          title: Name
          type: string
        team_name:
          description: Name of the team the secret belongs to
          title: Team Name
          type: string
      required:
        - created_at
        - name
        - team_name
      title: SecretV1
      type: object
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        You must specify the scheme 'Api-Key' in the Authorization header. For
        example, `Authorization: Api-Key <Your_Api_Key>`

````