---
docId: doc_d549b8d5633048fa8fe810dcae60a3a0
title: Create a secret
description: "Stores a workspace credential and returns its id without exposing the value in the response."
api:
  group: herramientas/secretos
  auth: bearer
  operations:
    - operationId: createSecret
      method: POST
      path: /v1/secrets
      postmanName: Create a secret
---

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

# Create a secret

Stores a credential as a workspace secret and returns its `id`. You send the value only when creating or [rotating](/api-reference/secrets/rotate) it. Then bind that id to the credential field (slot) of the resource that will use it.

<Note type="warning">

Do not log or display the value after sending it. If an AI assistant creates the secret for you, the value goes through that conversation: to avoid it, create the secret from Platica and bind it by its `id`.

</Note>

## Example

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

```bash
curl https://api.platic.ai/v1/secrets \
  -H "Authorization: Bearer $PLATIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "name": "Orders API", "kind": "api_key", "value": "your-api-key" }'
```

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

```ts
await platic.secrets.create({ name: "Orders API", kind: "api_key", value: "your-api-key" });
```

</Ways.Way>
</Ways>

## Request body

| Field | Type | Description | Required |
|-------|------|-------------|----------|
| `name` | string | Name to recognize it, 1 to 150 characters | ✓ |
| `kind` | string | What the value is: `api_key`, `bearer`, `password`, or `signing_key`. It does not change how it is sent | ✓ |
| `value` | string | The credential. 1 to 16,384 characters | ✓ |
| `expiresAt` | string | A future date in ISO 8601 with a time zone. At that moment the secret stops working | — |

```json
{
  "name": "Acme Store · Orders API",
  "kind": "bearer",
  "value": "sk_test_example",
  "expiresAt": "2027-01-31T06:00:00.000Z"
}
```

## Response

`201 Created`. The response has the secret's details, never the value.

```json
{
  "status": "success",
  "message": "Secret created successfully",
  "data": {
    "id": "5d0c7a1e9b3f4a6c8e2d1f0b7a9c3e5d6f8a0b2c4d6e8f1a3b5c7d9e0f2a4b6c",
    "name": "Acme Store · Orders API",
    "kind": "bearer",
    "status": "active",
    "revision": 1,
    "createdAt": "2026-10-28T12:05:00.000Z",
    "updatedAt": "2026-10-28T12:05:00.000Z",
    "expiresAt": "2027-01-31T06:00:00.000Z",
    "nextStep": "Bind it to the slot that needs it with POST /v1/tools/apis/{integrationId}/secrets (custom API) or POST /v1/tools/mcp/{mcpId}/secrets (MCP server) and { \"slot\": \"<slot>\", \"secretId\": \"5d0c7a1e9b3f4a6c8e2d1f0b7a9c3e5d6f8a0b2c4d6e8f1a3b5c7d9e0f2a4b6c\" }. The slots of a tool are listed in its \"secrets\". A webhook takes it in \"secrets\" when you create or update it."
  }
}
```

### Response fields

| Field | Type | Description |
|-------|------|-------------|
| `id` | string | Id of the secret. It is what you bind to a slot; it is not the value |
| `name` | string | The name you sent |
| `kind` | string | The type you sent |
| `status` | string | `active` when created |
| `revision` | number | `1` when created. Goes up with every change |
| `createdAt`, `updatedAt` | string \| null | Dates in ISO 8601 |
| `expiresAt` | string | Only appears if you sent an expiration |
| `nextStep` | string | English text that says what comes next: bind the secret to a slot. It is for people and assistants; do not program against its wording |

## Errors

| Status | `details.code` | When it happens |
|--------|----------------|-----------------|
| `400` | `INVALID_REQUEST` | A field is missing, `kind` is not valid, or `expiresAt` is not an ISO 8601 date. `details.issues` has the list of problems, without repeating the value |
| `400` | `INVALID_EXPIRY` | `expiresAt` is not in the future |
| `403` | `FORBIDDEN` | The person behind the token cannot manage secrets |

## Notes

- Continue by binding it: [to an API](/api-reference/custom-apis/bind-secret), [to an MCP server](/api-reference/mcp-servers/bind-secret), or [to a webhook](/api-reference/webhooks/bind-secrets). You can also send `"secrets": { "<slot>": "<secretId>" }` when you create or update the resource.
- To change the value later, use [rotate a secret](/api-reference/secrets/rotate).
