# createConversation

```graphql
mutation CreateConversation($input: CreateConversationInput!) {
  createConversation(input: $input) {
    id
    projectId
    respondingAgentId
    type
    title
    summary
    status
    currentNode
    messageCount
    lastMessageAt
    metadata
    createdBy
    archivedAt
    createdAt
    updatedAt
    participants {
      id
      conversationId
      participantId
      participantType
      userId
      agentId
      displayName
      agentKind
      avatarUrl
      role
      lastReadMessageId
      notificationPreference
      joinedAt
    }
    activeAgentRun {
      runId
      conversationId
      messageId
      projectId
      requestedByUserId
      triggerPrincipalType
      triggerPrincipalId
      agentId
      status
      implementationKind
      workerKey
      sourceTargetKind
      sourceTargetEnvironmentId
      sourceTargetBranchId
      sourceTargetReleaseVersion
      runtimeTargetKind
      runtimeTargetEnvironmentId
      runtimeTargetBranchId
      parentConversationId
      parentRunId
      spawnedFromMessageId
      spawnedFromToolCallId
      inputAnchorMessageId
      handoffMessageId
      resolvedDeploymentId
      latestEventId
      latestExternalEventSequence
      waitingToolCallId
      waitingToolName
      terminalErrorCode
      terminalErrorMessage
      createdAt
      startedAt
      finishedAt
      runSnapshot
    }
    initialMessageId
  }
}
```

Start a conversation in a project when a user or an agent opens a new thread, optionally with a first user message; a retry with the same idempotency key returns the same conversation. Requires project.conversations.create.

## Arguments

| Name                     | Type                                  | Required | Description                                                                                                                      |
| ------------------------ | ------------------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------- |
| `input`                  | CreateConversationInput!              | Yes      |                                                                                                                                  |
| `input.projectReference` | String                                |          |                                                                                                                                  |
| `input.type`             | String                                |          |                                                                                                                                  |
| `input.title`            | String                                |          |                                                                                                                                  |
| `input.metadata`         | JSON                                  |          |                                                                                                                                  |
| `input.idempotencyKey`   | String                                |          | Retrying with the same key and the same input returns the same conversation; a different input fails with IDEMPOTENCY\_CONFLICT. |
| `input.initialMessage`   | CreateConversationInitialMessageInput |          | A first user message stored atomically with the conversation.                                                                    |

## Variables

```json
{
  "input": {}
}
```

## Responses

| Status | Description                                   |
| ------ | --------------------------------------------- |
| 200    | The Conversation! in data.createConversation. |

## 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 CreateConversation($input: CreateConversationInput!) {\n  createConversation(input: $input) {\n    id\n    projectId\n    respondingAgentId\n    type\n    title\n    summary\n    status\n    currentNode\n    messageCount\n    lastMessageAt\n    metadata\n    createdBy\n    archivedAt\n    createdAt\n    updatedAt\n    participants {\n      id\n      conversationId\n      participantId\n      participantType\n      userId\n      agentId\n      displayName\n      agentKind\n      avatarUrl\n      role\n      lastReadMessageId\n      notificationPreference\n      joinedAt\n    }\n    activeAgentRun {\n      runId\n      conversationId\n      messageId\n      projectId\n      requestedByUserId\n      triggerPrincipalType\n      triggerPrincipalId\n      agentId\n      status\n      implementationKind\n      workerKey\n      sourceTargetKind\n      sourceTargetEnvironmentId\n      sourceTargetBranchId\n      sourceTargetReleaseVersion\n      runtimeTargetKind\n      runtimeTargetEnvironmentId\n      runtimeTargetBranchId\n      parentConversationId\n      parentRunId\n      spawnedFromMessageId\n      spawnedFromToolCallId\n      inputAnchorMessageId\n      handoffMessageId\n      resolvedDeploymentId\n      latestEventId\n      latestExternalEventSequence\n      waitingToolCallId\n      waitingToolName\n      terminalErrorCode\n      terminalErrorMessage\n      createdAt\n      startedAt\n      finishedAt\n      runSnapshot\n    }\n    initialMessageId\n  }\n}",
  "variables": {
    "input": {}
  }
}'
```

## Example response

```json
{
  "data": {
    "createConversation": {
      "id": "string",
      "projectId": "string",
      "respondingAgentId": "string",
      "type": "string",
      "title": "string",
      "summary": "string",
      "status": "string",
      "currentNode": "string",
      "messageCount": 0,
      "lastMessageAt": "string",
      "metadata": {},
      "createdBy": "string",
      "archivedAt": "string",
      "createdAt": "string",
      "updatedAt": "string",
      "participants": [
        {
          "id": "string",
          "conversationId": "string",
          "participantId": "string",
          "participantType": "string",
          "userId": "string",
          "agentId": "string",
          "displayName": "string",
          "agentKind": "string",
          "avatarUrl": "https://example.com",
          "role": "string",
          "lastReadMessageId": "string",
          "notificationPreference": "string",
          "joinedAt": "string"
        }
      ],
      "activeAgentRun": {
        "runId": "string",
        "conversationId": "string",
        "messageId": "string",
        "projectId": "string",
        "requestedByUserId": "string",
        "triggerPrincipalType": "string",
        "triggerPrincipalId": "string",
        "agentId": "string",
        "status": "string",
        "implementationKind": "string",
        "workerKey": "string",
        "sourceTargetKind": "string",
        "sourceTargetEnvironmentId": "string",
        "sourceTargetBranchId": "string",
        "sourceTargetReleaseVersion": "string",
        "runtimeTargetKind": "string",
        "runtimeTargetEnvironmentId": "string",
        "runtimeTargetBranchId": "string",
        "parentConversationId": "string",
        "parentRunId": "string",
        "spawnedFromMessageId": "string",
        "spawnedFromToolCallId": "string",
        "inputAnchorMessageId": "string",
        "handoffMessageId": "string",
        "resolvedDeploymentId": "string",
        "latestEventId": 0,
        "latestExternalEventSequence": 0,
        "waitingToolCallId": "string",
        "waitingToolName": "string",
        "terminalErrorCode": "string",
        "terminalErrorMessage": "string",
        "createdAt": "string",
        "startedAt": "string",
        "finishedAt": "string",
        "runSnapshot": {}
      },
      "initialMessageId": "string"
    }
  }
}
```
