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

# Supabase API Key

> Learn how to automatically rotate Supabase API keys.

<Note>
  **Rotation Type: Dual-Phase**

  This rotation maintains two active credential sets with overlapping validity, ensuring zero-downtime during rotation cycles.
</Note>

## Prerequisites

* Create a [Supabase Connection](/integrations/app-connections/supabase). That connection is used to create and delete API keys on your behalf during rotation.

## Create a Supabase API Key Rotation in Infisical

<Tabs>
  <Tab title="Infisical UI">
    1. Navigate to your Secret Manager Project's Dashboard and select **Add Secret Rotation** from the actions dropdown.

           <img src="https://mintlify.s3.us-west-1.amazonaws.com/infisical/images/secret-rotations-v2/generic/add-secret-rotation.png" alt="Secret Manager Dashboard" />

    2. Select the **Supabase API Key** option.

           <img src="https://mintlify.s3.us-west-1.amazonaws.com/infisical/images/secret-rotations-v2/supabase-api-key/select-supabase-api-key.png" alt="Select Supabase API Key" />

    3. Configure the rotation behavior, then click **Next**.

    * **Supabase Connection** – The connection that will create and delete API keys during rotation.
    * **Rotation Interval** – The interval, in days, after which a rotation is triggered.
    * **Rotate At** – The local time of day when rotation runs once the interval has elapsed.
    * **Auto-Rotation Enabled** – Whether to rotate automatically on the interval. Turn off to rotate only manually or pause rotation.

          <img src="https://mintlify.s3.us-west-1.amazonaws.com/infisical/images/secret-rotations-v2/supabase-api-key/configuration.png" alt="Rotation Configuration" />

    4. Set the Supabase API key parameters, then click **Next**.

    * **Project** – The Supabase project to rotate the API key for.
    * **Key Type** – The type of the API key to rotate:
      * `publishable` – The public `anon` key, safe to expose in client-side code. It is used with Row Level Security (RLS) policies to control per-user access.
      * `secret` – The `service_role` key, which bypasses RLS entirely and has full access to your project's data. Must be kept server-side only.

            <img src="https://mintlify.s3.us-west-1.amazonaws.com/infisical/images/secret-rotations-v2/supabase-api-key/parameters.png" alt="Rotation Parameters" />

    5. Specify the secret name that the rotated API key will be mapped to. Then click **Next**.

    * **API Key** – The name of the secret in Infisical where the rotated API key value will be stored.

          <img src="https://mintlify.s3.us-west-1.amazonaws.com/infisical/images/secret-rotations-v2/supabase-api-key/secrets-mapping.png" alt="Rotation Secrets Mapping" />

    6. Give your rotation a name and description (optional). Then click **Next**.

    * **Name** – A slug-friendly name for this rotation configuration.
    * **Description** (optional) – Notes about this rotation.

          <img src="https://mintlify.s3.us-west-1.amazonaws.com/infisical/images/secret-rotations-v2/supabase-api-key/details.png" alt="Rotation Details" />

    7. Review your configuration, then click **Create Secret Rotation**.

           <img src="https://mintlify.s3.us-west-1.amazonaws.com/infisical/images/secret-rotations-v2/supabase-api-key/review.png" alt="Rotation Review" />

    8. Your **Supabase API Key** rotation is created. The current API key is available as a secret at the mapped path. Rotations will create a new key, switch the active secret to it, then revoke the previous key for zero-downtime rotation.

           <img src="https://mintlify.s3.us-west-1.amazonaws.com/infisical/images/secret-rotations-v2/supabase-api-key/created.png" alt="Rotation Created" />
  </Tab>

  <Tab title="API">
    To create a Supabase API Key rotation, call the [Create Supabase API Key Rotation](/api-reference/endpoints/secret-rotations/supabase-api-key/create) API endpoint.

    ### Sample request

    ```bash Request theme={"dark"}
    curl --request POST \
      --url https://us.infisical.com/api/v2/secret-rotations/supabase-api-key \
      --header 'Content-Type: application/json' \
      --data '{
        "name": "my-supabase-rotation",
        "projectId": "<project-id>",
        "description": "Supabase API key rotation",
        "connectionId": "<supabase-connection-id>",
        "environment": "dev",
        "secretPath": "/",
        "isAutoRotationEnabled": true,
        "rotationInterval": 30,
        "rotateAtUtc": {
          "hours": 0,
          "minutes": 0
        },
        "parameters": {
          "projectRef": "<supabase-project-ref>",
          "keyType": "secret"
        },
        "secretsMapping": {
          "apiKey": "SUPABASE_API_KEY"
        }
      }'
    ```

    ### Sample response

    ```bash Response theme={"dark"}
    {
      "secretRotation": {
        "id": "<rotation-id>",
        "name": "my-supabase-rotation",
        "description": "Supabase API key rotation",
        "secretsMapping": {
          "apiKey": "SUPABASE_API_KEY"
        },
        "isAutoRotationEnabled": true,
        "activeIndex": 0,
        "connectionId": "<supabase-connection-id>",
        "rotationInterval": 30,
        "rotateAtUtc": { "hours": 0, "minutes": 0 },
        "type": "supabase-api-key",
        "parameters": {
          "projectRef": "<supabase-project-ref>",
          "keyType": "secret"
        }
      }
    }
    ```
  </Tab>
</Tabs>
