# createConversationMessageBranch

```graphql
mutation CreateConversationMessageBranch($conversationId: ID!, $messageId: ID!, $input: CreateConversationMessageBranchInput!) {
  createConversationMessageBranch(conversationId: $conversationId, messageId: $messageId, input: $input) {
    id
    conversationId
    parentId
    seq
    role
    createdBy
    senderType
    senderId
    senderDisplayName
    parts
    model
    runUsage {
      scope
      model
      inputTokens
      outputTokens
      cacheCreationInputTokens
      cacheReadInputTokens
      reasoningTokens
      totalTokens
      modelCalls
      costCredits
    }
    tokenUsage
    finishReason
    costCredits
    status
    editedAt
    idempotencyKey
    metadata
    createdAt
    updatedAt
  }
}
```

Create a sibling of a message with new parts when the user edits an earlier message and wants to keep the original reply; the new message gets the parent and role of the original and becomes the selected branch.

## Arguments

| Name                    | Type                                  | Required | Description                                                       |
| ----------------------- | ------------------------------------- | -------- | ----------------------------------------------------------------- |
| `conversationId`        | ID!                                   | Yes      |                                                                   |
| `messageId`             | ID!                                   | Yes      | Message to branch from; the new message gets its parent and role. |
| `input`                 | CreateConversationMessageBranchInput! | Yes      |                                                                   |
| `input.parts`           | JSON!                                 | Yes      | Parts of the new sibling message (1 to 200).                      |
| `input.composingUserId` | ID                                    |          | Must equal the authenticated user when set.                       |

## Variables

```json
{
  "conversationId": "string",
  "messageId": "string",
  "input": {
    "parts": {}
  }
}
```

## Responses

| Status | Description                                           |
| ------ | ----------------------------------------------------- |
| 200    | The Message! in data.createConversationMessageBranch. |

## Call it

```bash
curl -X POST "https://api.veryfront.com/graphql" \
  -H "Authorization: Bearer $VERYFRONT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "query": "mutation CreateConversationMessageBranch($conversationId: ID!, $messageId: ID!, $input: CreateConversationMessageBranchInput!) {\n  createConversationMessageBranch(conversationId: $conversationId, messageId: $messageId, input: $input) {\n    id\n    conversationId\n    parentId\n    seq\n    role\n    createdBy\n    senderType\n    senderId\n    senderDisplayName\n    parts\n    model\n    runUsage {\n      scope\n      model\n      inputTokens\n      outputTokens\n      cacheCreationInputTokens\n      cacheReadInputTokens\n      reasoningTokens\n      totalTokens\n      modelCalls\n      costCredits\n    }\n    tokenUsage\n    finishReason\n    costCredits\n    status\n    editedAt\n    idempotencyKey\n    metadata\n    createdAt\n    updatedAt\n  }\n}",
  "variables": {
    "conversationId": "string",
    "messageId": "string",
    "input": {
      "parts": {}
    }
  }
}'
```

## Example response

```json
{
  "data": {
    "createConversationMessageBranch": {
      "id": "string",
      "conversationId": "string",
      "parentId": "string",
      "seq": 0,
      "role": "string",
      "createdBy": "string",
      "senderType": "string",
      "senderId": "string",
      "senderDisplayName": "string",
      "parts": {},
      "model": "string",
      "runUsage": {
        "scope": "string",
        "model": "string",
        "inputTokens": 0,
        "outputTokens": 0,
        "cacheCreationInputTokens": 0,
        "cacheReadInputTokens": 0,
        "reasoningTokens": 0,
        "totalTokens": 0,
        "modelCalls": 0,
        "costCredits": "string"
      },
      "tokenUsage": {},
      "finishReason": "string",
      "costCredits": "string",
      "status": "string",
      "editedAt": "string",
      "idempotencyKey": "string",
      "metadata": {},
      "createdAt": "string",
      "updatedAt": "string"
    }
  }
}
```
