---
docId: doc_5a06f162f6d94a4890d3e88a7be6bec3
title: Bind a secret to an API
description: Bind a workspace secret to a custom API slot. The secret is authorized only for the API's current destination.
api:
  group: herramientas/apis-personalizadas
  auth: bearer
  operations:
    - operationId: bindApiToolSecret
      method: POST
      path: '/v1/tools/apis/{integrationId}/secrets'
      postmanName: Bind a secret to an API
---

<script>
  import { Ways } from '$lib/components';
</script>

# Bind a secret to an API

Complete a credential slot in `missing` or `needs_authorization`. Send `slot` and an existing secret’s `secretId`; do not send its value. Find the slot in the API’s `secrets[]`.

## Example

<Ways tabs="api,sdk">
<Ways.Way name="api">

```bash
curl -X POST "https://api.platic.ai/v1/tools/apis/$INTEGRATION_ID/secrets" \
  -H "Authorization: Bearer $PLATIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "slot": "auth.token",
  "secretId": "'"$SECRET_ID"'"
}'
```

</Ways.Way>
<Ways.Way name="sdk">

```ts
await platic.tools.apis.bindSecret("api_123", { slot: "auth.token", secretId: "secret_123" });
```

</Ways.Way>
</Ways>

## Path parameters

| Parameter | Type | Description | Required |
|-----------|------|-------------|----------|
| `integrationId` | string | Custom API ID | ✓ |

## Request body

```json
{
  "slot": "auth.token",
  "secretId": "5d0c7a1e9b3f4a6c8e2d1f0b7a9c3e5d6f8a0b2c4d6e8f1a3b5c7d9e0f2a4b6c"
}
```

| Field | Type | Description | Required |
|-------|------|-------------|----------|
| `slot` | string | The slot, as it appears in `secrets[].slot`: `auth.token`, `auth.password`, `auth.value`, `encryptPayload.key`, `header:<name>` or `variable:<name>` | ✓ |
| `secretId` | string | Secret ID, from [List secrets](/api-reference/secrets/list) or [Create a secret](/api-reference/secrets/create) | ✓ |

## Response

`data` has the complete API, with the fields of [Get an API](/api-reference/custom-apis/get#response-fields). The slot ends up in `authorized`.

```json
{
  "status": "success",
  "message": "Secret bound successfully",
  "data": {
    "id": "RuzoaswTBBrhutHyKYZn",
    "toolName": "api_order_lookup",
    "name": "order_lookup",
    "description": "Looks up the status of an Example Store order by its number. Use it when the customer asks where their order is.",
    "status": "draft",
    "version": 2,
    "variables": [
      {
        "name": "orderId",
        "type": "string",
        "description": "Order number, as it appears in the confirmation email.",
        "required": true,
        "mode": "ai"
      }
    ],
    "request": {
      "method": "GET",
      "url": "https://api.example-store.com/orders/{{orderId}}",
      "headers": [{ "key": "Accept", "value": "application/json" }],
      "auth": { "type": "bearer" }
    },
    "createdAt": "2026-10-28T12:05:03.902Z",
    "updatedAt": "2026-10-28T12:10:02.118Z",
    "lastTest": null,
    "verified": false,
    "secrets": [
      {
        "slot": "auth.token",
        "state": "authorized",
        "secretId": "5d0c7a1e9b3f4a6c8e2d1f0b7a9c3e5d6f8a0b2c4d6e8f1a3b5c7d9e0f2a4b6c"
      }
    ],
    "secretsRedacted": true,
    "nextStep": "Run a real test with POST /v1/tools/apis/RuzoaswTBBrhutHyKYZn/test and dryRun false. Enabling requires a successful real test of the current configuration."
  }
}
```

## Errors

| Status | `details.code` | When |
|--------|----------------|------|
| `400` | `INVALID_REQUEST` | `slot` or `secretId` is missing. `details.issues` has the list of problems |
| `400` | `SECRET_SLOT_INVALID` | That slot does not exist in the API's current configuration |
| `400` | `SECRET_DESTINATION_INVALID` | The API does not have a valid `https` URL. Complete it before binding |
| `400` | `SECRET_VARIABLE_CONFIGURATION_INVALID` | A `secret` variable is misused: it can only go in headers, query parameters or body |
| `403` | `FORBIDDEN` | The person behind the token cannot use secrets or does not have access to Integrations |
| `404` | `SECRET_NOT_FOUND` | The secret does not exist in this workspace |
| `404` | `NOT_FOUND` | The API does not exist in this workspace |
| `409` | `SECRET_USE_REVOKED` | The secret is revoked or expired |
| `409` | `SECRET_CHANGED` | The secret changed while it was being bound. Repeat the call |
| `409` | `RESOURCE_CHANGED` | The API changed while it was being bound. Repeat the call |
| `409` | `SECRET_BINDING_LIMIT` | The API already has the maximum number of bound secrets |

## Notes

- The secret is authorized for that slot and for the API's current destination. If you later [update](/api-reference/custom-apis/update) the definition, the slot goes to `needs_authorization` and you have to repeat this call.
- Binding another secret to a slot that already had one replaces it.
- Binding changes the credentials the API was tested with. If it was already verified, [test it again](/api-reference/custom-apis/test) before publishing.
- To bind several slots in one call, send `"secrets": { "<slot>": "<secretId>" }` in [Update an API](/api-reference/custom-apis/update) or in [Create an API](/api-reference/custom-apis/create).
- The same secret can be bound to several slots and to several resources.
