# Create Captain (https://docs.capy.ai/api-reference/captains/create-captain)

`POST https://api.capy.ai/api/v1/captains`

## Authorization

Send an API key as a bearer token: `Authorization: Bearer $CAPY_API_KEY`. See https://docs.capy.ai/api-reference/authentication.md.

## Request body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `requestId` | string | yes |  |
| `projectId` | string | yes |  |
| `name` | string | yes |  |
| `brief` | string | no | The Captain's first message from you: what it is for and what to start on. Absent, the Captain greets you and asks. |
| `model` | ModelSelection | no |  |
| `avatar` | CaptainAvatar | no | Absent, the Captain takes the first preset face on a blue background. |
| `authorId` | string | no | The active member of the key's organization who owns the Captain. A Captain needs a human owner, so a service key must name one; a personal key owns it itself when absent. A replayed `requestId` returns the existing Captain unchanged. |

## Responses

- `200` Captain: `CaptainEncoded`
- `400` capy/InvalidRequest | ModelSelection.Rejected: `capy_InvalidRequestEncoded \| ModelSelection.RejectedEncoded`
- `401` capy/Unauthorized: `capy_UnauthorizedEncoded`
- `402` capy/PaidFeatureUnavailable: `capy_PaidFeatureUnavailableEncoded`
- `403` capy/Forbidden: `capy_ForbiddenEncoded \| capy_ForbiddenEncoded`
- `404` capy/ProjectNotFound: `capy_ProjectNotFoundEncoded`
- `429` capy/RateLimited: `capy_RateLimitedEncoded`
- `503` capy/BillingAuthorityUnavailable: `capy_BillingAuthorityUnavailableEncoded`

## Example

```bash
curl -X POST "https://api.capy.ai/api/v1/captains" \
  -H "Authorization: Bearer $CAPY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"requestId":"<requestId>","projectId":"<projectId>","name":"<name>"}'
```

## Referenced schemas

```json
{
  "CaptainEncoded": {
    "type": "object",
    "properties": {
      "id": {
        "type": "string"
      },
      "projectId": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "null"
          }
        ]
      },
      "authorId": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "null"
          }
        ]
      },
      "previousAuthorId": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "null"
          }
        ]
      },
      "title": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "null"
          }
        ]
      },
      "titleCustom": {
        "type": "boolean"
      },
      "status": {
        "type": "string",
        "enum": [
          "working",
          "waiting",
          "idle",
          "failed",
          "archived"
        ]
      },
      "archived": {
        "type": "boolean"
      },
      "lastModelId": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "null"
          }
        ]
      },
      "modelDefault": {
        "$ref": "#/components/schemas/DefaultedModel",
        "description": "On the create response when the request named no `model`: the model the thread starts on and the default that supplied it, with any default skipped because it could not run."
      },
      "queuedAt": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "null"
          }
        ]
      },
      "linearIssue": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/ThreadLinearIssue"
          },
          {
            "type": "null"
          }
        ]
      },
      "pullRequestAuthor": {
        "anyOf": [
          {
            "type": "string",
            "enum": [
              "user",
              "capy"
            ]
          },
          {
            "type": "null"
          }
        ],
        "description": "Who authors this thread's pull requests on GitHub: `capy` for the Capy GitHub App, `user` for the thread's acting human. Null means the acting human's Git identity preference decides."
      },
      "usage": {
        "$ref": "#/components/schemas/UsageTotalsEncoded"
      },
      "createdAt": {
        "type": "string"
      },
      "updatedAt": {
        "type": "string"
      },
      "lastActivityAt": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "null"
          }
        ]
      },
      "hasUnreads": {
        "type": "boolean"
      },
      "mentionCount": {
        "type": "integer"
      },
      "owed": {
        "type": "boolean"
      },
      "needsYou": {
        "type": "boolean"
      },
      "ask": {
        "$ref": "#/components/schemas/ThreadAsk"
      },
      "crewNeedsYou": {
        "type": "integer"
      },
      "participated": {
        "type": "boolean"
      },
      "crewMentionCount": {
        "type": "integer"
      },
      "captain": {
        "$ref": "#/components/schemas/ThreadCaptain"
      },
      "crewCount": {
        "type": "integer"
      },
      "member": {
        "type": "boolean"
      },
      "subscribed": {
        "type": "boolean"
      },
      "personal": {
        "type": "boolean"
      },
      "visibility": {
        "type": "string",
        "enum": [
          "org",
          "private"
        ]
      },
      "name": {
        "type": "string"
      },
      "avatar": {
        "$ref": "#/components/schemas/CaptainAvatar"
      },
      "description": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "null"
          }
        ],
        "description": "A short public label saying whose Captain this is and what it covers, at most 140 characters of plain text, for attribution and discovery. Null when unset."
      }
    },
    "required": [
      "id",
      "projectId",
      "authorId",
      "previousAuthorId",
      "title",
      "titleCustom",
      "status",
      "archived",
      "lastModelId",
      "queuedAt",
      "linearIssue",
      "pullRequestAuthor",
      "usage",
      "createdAt",
      "updatedAt",
      "lastActivityAt",
      "hasUnreads",
      "mentionCount",
      "owed",
      "member",
      "name",
      "avatar",
      "description"
    ],
    "additionalProperties": false
  },
  "DefaultedModel": {
    "type": "object",
    "properties": {
      "modelId": {
        "type": "string"
      },
      "source": {
        "type": "string",
        "enum": [
          "personal",
          "service_user",
          "slack",
          "linear",
          "org",
          "platform"
        ],
        "description": "Which default supplied the model: `personal` is the human's own default, `service_user` the service user's, `slack` the person's Slack default, `linear` the person's Linear default, `org` the organization default, and `platform` Capy's default."
      },
      "skipped": {
        "type": "array",
        "items": {
          "$ref": "#/components/schemas/ModelDefaultSkip"
        },
        "description": "Earlier defaults in the chain that could not run when the message was admitted, in chain order."
      }
    },
    "required": [
      "modelId",
      "source",
      "skipped"
    ],
    "additionalProperties": false
  },
  "ModelDefaultSkip": {
    "type": "object",
    "properties": {
      "modelId": {
        "type": "string"
      },
      "source": {
        "type": "string",
        "enum": [
          "personal",
          "service_user",
          "slack",
          "linear",
          "org",
          "platform"
        ],
        "description": "Which default supplied the model: `personal` is the human's own default, `service_user` the service user's, `slack` the person's Slack default, `linear` the person's Linear default, `org` the organization default, and `platform` Capy's default."
      },
      "reason": {
        "type": "string",
        "description": "Why this default could not run."
      }
    },
    "required": [
      "modelId",
      "source",
      "reason"
    ],
    "additionalProperties": false
  },
  "ThreadLinearIssue": {
    "type": "object",
    "properties": {
      "key": {
        "type": "string"
      },
      "url": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "null"
          }
        ]
      }
    },
    "required": [
      "key",
      "url"
    ],
    "additionalProperties": false
  },
  "UsageTotalsEncoded": {
    "type": "object",
    "properties": {
      "llmCredits": {
        "anyOf": [
          {
            "type": "number"
          },
          {
            "type": "string",
            "enum": [
              "Infinity",
              "-Infinity",
              "NaN"
            ]
          }
        ]
      },
      "imageCredits": {
        "anyOf": [
          {
            "type": "number"
          },
          {
            "type": "string",
            "enum": [
              "Infinity",
              "-Infinity",
              "NaN"
            ]
          }
        ]
      },
      "vmCredits": {
        "anyOf": [
          {
            "type": "number"
          },
          {
            "type": "string",
            "enum": [
              "Infinity",
              "-Infinity",
              "NaN"
            ]
          }
        ]
      },
      "totalCredits": {
        "anyOf": [
          {
            "type": "number"
          },
          {
            "type": "string",
            "enum": [
              "Infinity",
              "-Infinity",
              "NaN"
            ]
          }
        ]
      }
    },
    "required": [
      "llmCredits",
      "imageCredits",
      "vmCredits",
      "totalCredits"
    ],
    "additionalProperties": false
  },
  "ThreadAsk": {
    "type": "object",
    "properties": {
      "key": {
        "type": "string"
      },
      "kind": {
        "type": "string",
        "enum": [
          "conversation",
          "environment",
          "mcp",
          "credits",
          "desktop",
          "feedback",
          "terminal"
        ]
      },
      "text": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "null"
          }
        ]
      },
      "causeKey": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "null"
          }
        ]
      }
    },
    "required": [
      "key",
      "kind",
      "text",
      "causeKey"
    ],
    "additionalProperties": false
  },
  "ThreadCaptain": {
    "type": "object",
    "properties": {
      "jamId": {
        "type": "string"
      },
      "name": {
        "type": "string"
      },
      "avatar": {
        "$ref": "#/components/schemas/CaptainAvatar"
      }
    },
    "required": [
      "jamId",
      "name",
      "avatar"
    ],
    "additionalProperties": false
  },
  "CaptainAvatar": {
    "type": "object",
    "properties": {
      "kind": {
        "type": "string",
        "enum": [
          "preset",
          "emoji"
        ]
      },
      "value": {
        "type": "string"
      },
      "background": {
        "type": "string"
      },
      "image": {
        "type": "string"
      },
      "library": {
        "type": "string",
        "pattern": "^cimg_[0-9A-HJKMNP-TV-Z]{26}$"
      }
    },
    "required": [
      "kind",
      "value",
      "background"
    ],
    "additionalProperties": false
  },
  "capy_InvalidRequestEncoded": {
    "type": "object",
    "properties": {
      "_tag": {
        "type": "string",
        "enum": [
          "capy/InvalidRequest"
        ]
      },
      "message": {
        "type": "string"
      }
    },
    "required": [
      "_tag",
      "message"
    ],
    "additionalProperties": false
  },
  "ModelSelection.RejectedEncoded": {
    "type": "object",
    "properties": {
      "_tag": {
        "type": "string",
        "enum": [
          "ModelSelection.Rejected"
        ]
      },
      "message": {
        "type": "string"
      },
      "candidates": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "entryId": {
              "type": "string"
            },
            "name": {
              "type": "string"
            },
            "billingLabel": {
              "type": "string"
            }
          },
          "required": [
            "entryId",
            "name",
            "billingLabel"
          ],
          "additionalProperties": false
        }
      },
      "rejection": {
        "type": "string",
        "enum": [
          "disconnected",
          "not_connected"
        ]
      },
      "modelId": {
        "type": "string"
      },
      "service": {
        "anyOf": [
          {
            "type": "string",
            "enum": [
              "codex",
              "copilot",
              "supergrok",
              "claude"
            ]
          },
          {
            "$ref": "#/components/schemas/UnsupportedMember"
          }
        ]
      },
      "health": {
        "type": "object",
        "properties": {
          "state": {
            "type": "string",
            "enum": [
              "connected",
              "not_connected",
              "signed_out",
              "disabled",
              "usage_exhausted"
            ]
          },
          "kind": {
            "type": "string",
            "enum": [
              "subscription",
              "key"
            ]
          },
          "provider": {
            "type": "string"
          },
          "action": {
            "type": "string",
            "enum": [
              "connect",
              "reconnect",
              "replace_key",
              "enable"
            ]
          },
          "resetsAt": {
            "type": "string"
          },
          "limitedModel": {
            "type": "string"
          }
        },
        "required": [
          "state",
          "kind",
          "provider"
        ],
        "additionalProperties": false
      }
    },
    "required": [
      "_tag",
      "message",
      "candidates"
    ],
    "additionalProperties": false
  },
  "UnsupportedMember": {
    "type": "string"
  },
  "capy_UnauthorizedEncoded": {
    "type": "object",
    "properties": {
      "_tag": {
        "type": "string",
        "enum": [
          "capy/Unauthorized"
        ]
      }
    },
    "required": [
      "_tag"
    ],
    "additionalProperties": false
  },
  "capy_PaidFeatureUnavailableEncoded": {
    "type": "object",
    "properties": {
      "_tag": {
        "type": "string",
        "enum": [
          "capy/PaidFeatureUnavailable"
        ]
      },
      "feature": {
        "type": "string",
        "enum": [
          "small",
          "medium",
          "large",
          "ultra",
          "hyper",
          "bigguy",
          "byok"
        ]
      }
    },
    "required": [
      "_tag",
      "feature"
    ],
    "additionalProperties": false
  },
  "capy_ForbiddenEncoded": {
    "type": "object",
    "properties": {
      "_tag": {
        "type": "string",
        "enum": [
          "capy/Forbidden"
        ]
      },
      "mfaRequiredOrgId": {
        "type": "string"
      },
      "ssoRequired": {
        "type": "boolean"
      },
      "passkeyRequired": {
        "type": "boolean"
      }
    },
    "required": [
      "_tag"
    ],
    "additionalProperties": false
  },
  "capy_ProjectNotFoundEncoded": {
    "type": "object",
    "properties": {
      "_tag": {
        "type": "string",
        "enum": [
          "capy/ProjectNotFound"
        ]
      },
      "projectId": {
        "type": "string"
      }
    },
    "required": [
      "_tag",
      "projectId"
    ],
    "additionalProperties": false
  },
  "capy_RateLimitedEncoded": {
    "type": "object",
    "properties": {
      "_tag": {
        "type": "string",
        "enum": [
          "capy/RateLimited"
        ]
      },
      "retryAfterSeconds": {
        "type": "integer"
      }
    },
    "required": [
      "_tag",
      "retryAfterSeconds"
    ],
    "additionalProperties": false
  },
  "capy_BillingAuthorityUnavailableEncoded": {
    "type": "object",
    "properties": {
      "_tag": {
        "type": "string",
        "enum": [
          "capy/BillingAuthorityUnavailable"
        ]
      }
    },
    "required": [
      "_tag"
    ],
    "additionalProperties": false
  },
  "CreateCaptainRequest": {
    "type": "object",
    "properties": {
      "requestId": {
        "type": "string",
        "allOf": [
          {
            "minLength": 1
          },
          {
            "maxLength": 191
          }
        ]
      },
      "projectId": {
        "type": "string"
      },
      "name": {
        "type": "string",
        "allOf": [
          {
            "minLength": 1
          },
          {
            "maxLength": 100
          }
        ]
      },
      "brief": {
        "type": "string",
        "description": "The Captain's first message from you: what it is for and what to start on. Absent, the Captain greets you and asks."
      },
      "model": {
        "$ref": "#/components/schemas/ModelSelection"
      },
      "avatar": {
        "$ref": "#/components/schemas/CaptainAvatar",
        "description": "Absent, the Captain takes the first preset face on a blue background."
      },
      "authorId": {
        "type": "string",
        "description": "The active member of the key's organization who owns the Captain. A Captain needs a human owner, so a service key must name one; a personal key owns it itself when absent. A replayed `requestId` returns the existing Captain unchanged."
      }
    },
    "required": [
      "requestId",
      "projectId",
      "name"
    ],
    "additionalProperties": false
  },
  "ModelSelection": {
    "type": "object",
    "properties": {
      "modelId": {
        "type": "string"
      },
      "reasoningMode": {
        "type": "string",
        "enum": [
          "none",
          "instant",
          "minimal",
          "low",
          "medium",
          "high",
          "xhigh",
          "max"
        ]
      },
      "modes": {
        "type": "object",
        "properties": {
          "fast": {
            "type": "boolean"
          },
          "pro": {
            "type": "boolean"
          },
          "ultrafast": {
            "type": "boolean"
          },
          "daybreak": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      }
    },
    "required": [
      "modelId"
    ],
    "additionalProperties": false
  }
}
```

Full document: https://docs.capy.ai/openapi.json