# Generate P2P or Group Conversation Sharing Code

`POST /api/conversations/shares/code/generate`

### Overview
Generates a secure claim code that allows colleagues to read or copy the conversation thread.

### Authentication & Headers
- **Auth**: Bearer Token
- **Required Header**: `API-Version: 1`

### Parameters & Request Body Fields
- **`conversation_id`** *(string, required)*: Target conversation to share.
- **`expires_hours`** *(integer, optional, default: 48)*: Code validity duration in hours.
- **`max_claims`** *(integer, optional, default: 5)*: Maximum number of claims allowed.

## Request body

Content type: `application/json`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `resource_type` | string | no |  |
| `resource_id` | string | yes |  |
| `grantee_type` | string | yes |  |
| `grant_type` | string | no |  |
| `max_claims` | integer | no |  |
| `expires_in_hours` | integer \| null | no |  |
| `description` | string \| null | no |  |
| `allow_model_usage` | boolean | no |  |

```json
{
  "resource_type": "agent",
  "resource_id": "string",
  "grantee_type": "string",
  "grant_type": "use",
  "max_claims": 1,
  "expires_in_hours": 0,
  "description": "string",
  "allow_model_usage": false
}
```

## Responses

### 201 — Share code generated successfully

### 400 — Bad Request - The request parameters or headers are invalid (e.g. unsupported API-Version).

### 401 — Unauthorized - Missing, invalid, or expired JWT Bearer token.

### 403 — Forbidden - Insufficient role permissions or resource access denied by RBAC policy.

### 404 — Not Found - The requested resource ID was not found.

### 422 — Validation Error

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `detail` | object[] | no |  |
| `detail[].loc` | string | integer[] | yes |  |
| `detail[].msg` | string | yes |  |
| `detail[].type` | string | yes |  |
| `detail[].input` | object | no |  |
| `detail[].ctx` | object | no |  |

```json
{
  "detail": [
    {
      "loc": [
        null
      ],
      "msg": "string",
      "type": "string",
      "input": null,
      "ctx": {}
    }
  ]
}
```

## Example

```bash
curl -X POST "$PINTER_URL/api/conversations/shares/code/generate" \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"resource_type":"agent","resource_id":"string","grantee_type":"string","grant_type":"use","max_claims":1,"expires_in_hours":0,"description":"string","allow_model_usage":false}'
```
