# profiles.create_from_context

`POST /api/public/v1/profiles/from-context`

Create a profile pinned to a fresh measured persona context.

- Capability: `profile.create`
- Command (idempotent): yes — send a `command_id`; resending the same id and body returns the stored receipt
- MCP tool: `profiles_create_from_context`

## Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `command_id` | body | string (uuid) | Yes | Client-generated UUID for this command. Send the same id (and body) again to get the stored receipt instead of a second change; a different body under the same id is CONFLICT. |
| `persona_context_id` | body | string (uuid) | Yes |  |
| `profile` | body | object | Yes |  |

## Response

`201` with `{ data, replayed: false, correlation_id }` the first time; `200` with `replayed: true` for a repeated `command_id`.

| Field | Type | Always present | Description |
|---|---|---|---|
| `data` | object | Yes |  |
| `data.profile_id` | string (uuid) | Yes |  |
| `data.number` | integer | Yes | (min -9007199254740991, max 9007199254740991) |
| `data.revision` | integer | Yes | (min -9007199254740991, max 9007199254740991) |
| `data.changed` | array<string> | Yes | Fields that changed; empty when the edit was a no-op (revision kept) |
| `correlation_id` | string (uuid) | Yes |  |
| `ok` | true | No |  |
| `operation_id` | string \| null | No |  |
| `state_version` | integer | No | (min 0) |
| `retryable` | false | No |  |
| `next` | null | No |  |
| `replayed` | boolean | No | true when this command_id was already applied and the stored receipt came back |

New fields can appear at any time; ignore the ones you do not know.

## Errors

| Code | HTTP | Retryable |
|---|---|---|
| `UNAUTHENTICATED` | 401 | No |
| `FORBIDDEN` | 403 | No |
| `RATE_LIMITED` | 429 | Yes |
| `VALIDATION_FAILED` | 422 | No |
| `CONFLICT` | 409 | No |
| `OUTCOME_UNKNOWN` | 202 | Yes |
| `DEPENDENCY_UNAVAILABLE` | 503 | Yes |
| `UNKNOWN` | 500 | No |

## Examples (curl)

```bash
curl -X POST "https://browlix.com/api/public/v1/profiles/from-context" \
  -H "Authorization: Bearer $BROWLIX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"command_id":"<uuid>","persona_context_id":"<persona_context_id>","profile":{"name":"Shop 01","config":{"os":"windows"}}}'
```

## Examples (TypeScript SDK)

```ts
import { Browlix } from "@browlix/sdk";

const bx = new Browlix({ apiKey: process.env.BROWLIX_API_KEY! });
const reply = await bx.call("profiles.create_from_context", { body: {"persona_context_id":"<persona_context_id>","profile":{"name":"Shop 01","config":{"os":"windows"}}} });
console.log(reply.data);
```

## Examples (Python)

```python
import os, uuid
import requests

r = requests.post(
    "https://browlix.com/api/public/v1/profiles/from-context",
    headers={"Authorization": f"Bearer {os.environ['BROWLIX_API_KEY']}"},
    json={"command_id":str(uuid.uuid4()),"persona_context_id":"<persona_context_id>","profile":{"name":"Shop 01","config":{"os":"windows"}}},
    timeout=60,
)
print(r.status_code, r.json())
```

## Examples (MCP)

```json
{
  "method": "tools/call",
  "params": {
    "name": "profiles_create_from_context",
    "arguments": {
      "persona_context_id": "<persona_context_id>",
      "profile": {
        "name": "Shop 01",
        "config": {
          "os": "windows"
        }
      }
    }
  }
}
```
