# Set user secret

`PUT https://api.instacloud.com/projects/{projectId}/secrets/{name}`

**Token scope:** `account` · `org` · `project` — read-only tokens refused (not a GET).

Set a user-defined secret at project or branch scope. Gated — secrets.write.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `projectId` | path | `string` | yes |  |
| `name` | path | `string` | yes | ^[A-Z][A-Z0-9_]{0,63}$ |

## Request body (application/json)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `value` | `string` | yes | secret value, max 8 KiB |
| `branch` | `string` | no | branch name (project-scoped if omitted) |
| `service` | `string` | no | bind to a branch service: "<type>/<name>" (requires branch) |

## Response 200

Default Response

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `ok` | `boolean` | no |  |

## Response 202

Default Response

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | `"approval_required"` | no |  |
| `approvalId` | `string` | no |  |
| `action` | `string` | no | the gated action, or a comma-joined compound set — prefer `actions` |
| `actions` | `string[]` | no | every capability this approval covers |
| `message` | `string` | no |  |
| `url` | `string` | no | the console page where a project admin reviews this request |
| `nextActions` | `object[]` | no |  |
| `nextActions.op` | `string` | yes | Neutral logical action id, e.g. "service.add" — NOT an operationId or a CLI/MCP tool name; each client maps it to its own surface. |
| `nextActions.reason` | `string` | yes | Natural-language, human/LLM-facing "why do this now". |
| `nextActions.args` | `object` | no | Suggested, flat named arguments; "<placeholder>"s where a value is unknown. |
| `nextActions.gated` | `boolean` | no | True if the action passes a governance gate. |

## Response 400

Default Response

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `error` | `string` | yes |  |

## Response 403

Default Response

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `error` | `string` | yes |  |

## Response 404

Default Response

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `error` | `string` | yes |  |

## Response 409

Default Response

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `error` | `string` | yes |  |
