# createConversationMessage

```graphql
mutation CreateConversationMessage($conversationId: ID!, $input: CreateConversationMessageInput!) {
  createConversationMessage(conversationId: $conversationId, 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
  }
}
```

Add a user message to a conversation to send what the user typed; the parent message defaults to the selected branch and an idempotency key makes retries safe.

## Arguments

| Name                    | Type                            | Required | Description                                                              |
| ----------------------- | ------------------------------- | -------- | ------------------------------------------------------------------------ |
| `conversationId`        | ID!                             | Yes      |                                                                          |
| `input`                 | CreateConversationMessageInput! | Yes      |                                                                          |
| `input.role`            | String!                         | Yes      | Message role; only user is accepted.                                     |
| `input.parts`           | JSON!                           | Yes      | Message parts (1 to 200).                                                |
| `input.parentId`        | ID                              |          | Parent message; defaults to the selected branch.                         |
| `input.composingUserId` | ID                              |          | Must equal the authenticated user when set.                              |
| `input.idempotencyKey`  | String                          |          | Retry key (up to 255 characters): the same key returns the same message. |
| `input.metadata`        | JSON                            |          | JSON object under 64 KB.                                                 |

## Variables

```json
{
  "conversationId": "string",
  "input": {
    "role": "user",
    "parts": {}
  }
}
```

## Responses

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

## 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 CreateConversationMessage($conversationId: ID!, $input: CreateConversationMessageInput!) {\n  createConversationMessage(conversationId: $conversationId, 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",
    "input": {
      "role": "user",
      "parts": {}
    }
  }
}'
```

## Example response

```json
{
  "data": {
    "createConversationMessage": {
      "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"
    }
  }
}
```
