# Chat

## Send a chat message

`POST https://app.italic.com/api/v2/runs`

Required permission: agent:chat. Asks Italic, as in the apps' chat, and answers when its reply is ready (up to a few minutes). Italic searches and reads the account's recordings and connected apps, and drafts emails, events and other writes; drafts the account's permissions say to ask about wait in Tasks. Ten messages a minute per key.

```json
{
  "openapi": "3.1.0",
  "info": {
    "title": "Italic API",
    "version": "2.0.0",
    "description": "Recordings, devices, chat, tasks, workflows, connectors and notifications. Text syncs to Italic; audio stays on the client."
  },
  "servers": [
    {
      "url": "https://app.italic.com/api/v2"
    }
  ],
  "paths": {
    "/runs": {
      "post": {
        "operationId": "sendMessage",
        "summary": "Send a chat message",
        "tags": [
          "Chat"
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            },
            "description": "Reuse the same key and body when retrying; the retry returns the first result with `replayed: true`. Keys are kept for 24 hours."
          }
        ],
        "description": "Required permission: agent:chat. Asks Italic, as in the apps' chat, and answers when its reply is ready (up to a few minutes). Italic searches and reads the account's recordings and connected apps, and drafts emails, events and other writes; drafts the account's permissions say to ask about wait in Tasks. Ten messages a minute per key.",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendMessage"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success. Writes without read permission return an ID and revision only.",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                },
                "description": "Request identifier for troubleshooting."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RunResult"
                }
              }
            }
          },
          "default": {
            "description": "Request failed. Errors include a stable code and a readable message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "An API key from Settings → Developers → API keys."
      },
      "accountSession": {
        "type": "http",
        "scheme": "bearer",
        "description": "A signed-in Italic account session. An API key cannot create or revoke keys."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "minLength": 0,
                "maxLength": 100
              },
              "message": {
                "type": "string",
                "minLength": 0,
                "maxLength": 1000
              }
            },
            "required": [
              "code",
              "message"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "error"
        ]
      },
      "Question": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256,
            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
          },
          "prompt": {
            "type": "string"
          },
          "about": {
            "type": "string"
          },
          "kind": {
            "type": "string",
            "enum": [
              "recipient",
              "account",
              "text"
            ]
          },
          "choices": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "label": {
                  "type": "string"
                },
                "detail": {
                  "type": "string"
                }
              },
              "required": [
                "label"
              ]
            }
          }
        },
        "required": [
          "id",
          "prompt",
          "kind",
          "choices"
        ]
      },
      "Run": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256,
            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
          },
          "source": {
            "type": "string",
            "enum": [
              "chat",
              "recording"
            ],
            "description": "`recording`: a workflow run a recording started."
          },
          "recordingId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256,
            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
          },
          "status": {
            "type": "string",
            "enum": [
              "running",
              "awaiting_approval",
              "completed",
              "failed",
              "cancelled"
            ]
          },
          "reply": {
            "type": "string",
            "description": "Italic's answer, in Markdown."
          },
          "error": {
            "type": "string"
          },
          "prompt": {
            "type": "string",
            "description": "Chat runs: what was asked."
          },
          "workflows": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 256,
                  "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
                },
                "name": {
                  "type": "string"
                }
              },
              "required": [
                "id",
                "name"
              ]
            }
          },
          "actions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RunAction"
            }
          },
          "questions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Question"
            }
          },
          "createdAt": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "updatedAt": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          }
        },
        "required": [
          "id",
          "source",
          "status",
          "actions",
          "questions",
          "createdAt",
          "updatedAt"
        ]
      },
      "RunAction": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256,
            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
          },
          "tool": {
            "type": "string",
            "description": "What the draft does: send_email, create_event, create_reminder, trash_email, send_webhook, create_notion_page, send_slack_message, save_to_drive, mcp_call and others."
          },
          "status": {
            "type": "string",
            "enum": [
              "proposed",
              "approved",
              "executing",
              "succeeded",
              "failed",
              "rejected",
              "uncertain"
            ],
            "description": "`proposed`: waiting for approval. `approved`: an iPhone adds it (reminders). `uncertain`: it may or may not have happened."
          },
          "executor": {
            "type": "string",
            "enum": [
              "cloud",
              "device"
            ]
          },
          "args": {
            "type": "object",
            "description": "The draft's fields, as the apps' card shows them."
          },
          "result": {
            "type": "object"
          },
          "link": {
            "type": "string",
            "description": "Opens what a finished action made, such as the sent email."
          },
          "workflowId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256,
            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
          }
        },
        "required": [
          "id",
          "tool",
          "status",
          "executor",
          "args"
        ]
      },
      "RunResult": {
        "type": "object",
        "properties": {
          "run": {
            "$ref": "#/components/schemas/Run"
          },
          "replayed": {
            "type": "boolean"
          }
        },
        "required": [
          "run"
        ]
      },
      "SendMessage": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string",
            "minLength": 1,
            "maxLength": 4000,
            "description": "What you ask Italic."
          },
          "history": {
            "type": "array",
            "maxItems": 31,
            "items": {
              "type": "object",
              "properties": {
                "role": {
                  "type": "string",
                  "enum": [
                    "user",
                    "assistant"
                  ]
                },
                "content": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 4000
                }
              },
              "required": [
                "role",
                "content"
              ],
              "additionalProperties": false
            },
            "description": "Earlier turns of this conversation, oldest first, so Italic can follow up. Italic keeps no conversation for API calls."
          },
          "timeZone": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64,
            "description": "IANA time zone for dates in the reply and drafts, such as America/New_York. Defaults to the account's."
          }
        },
        "required": [
          "message"
        ],
        "additionalProperties": false
      }
    }
  }
}
```

## Get a run

`GET https://app.italic.com/api/v2/runs/{id}`

Required permission: agent:chat. A chat run, or a workflow run from Tasks, as it is now.

```json
{
  "openapi": "3.1.0",
  "info": {
    "title": "Italic API",
    "version": "2.0.0",
    "description": "Recordings, devices, chat, tasks, workflows, connectors and notifications. Text syncs to Italic; audio stays on the client."
  },
  "servers": [
    {
      "url": "https://app.italic.com/api/v2"
    }
  ],
  "paths": {
    "/runs/{id}": {
      "get": {
        "operationId": "getRun",
        "summary": "Get a run",
        "tags": [
          "Chat"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256,
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
            }
          }
        ],
        "description": "Required permission: agent:chat. A chat run, or a workflow run from Tasks, as it is now.",
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success. Writes without read permission return an ID and revision only.",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                },
                "description": "Request identifier for troubleshooting."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RunResult"
                }
              }
            }
          },
          "default": {
            "description": "Request failed. Errors include a stable code and a readable message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "An API key from Settings → Developers → API keys."
      },
      "accountSession": {
        "type": "http",
        "scheme": "bearer",
        "description": "A signed-in Italic account session. An API key cannot create or revoke keys."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "minLength": 0,
                "maxLength": 100
              },
              "message": {
                "type": "string",
                "minLength": 0,
                "maxLength": 1000
              }
            },
            "required": [
              "code",
              "message"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "error"
        ]
      },
      "Question": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256,
            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
          },
          "prompt": {
            "type": "string"
          },
          "about": {
            "type": "string"
          },
          "kind": {
            "type": "string",
            "enum": [
              "recipient",
              "account",
              "text"
            ]
          },
          "choices": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "label": {
                  "type": "string"
                },
                "detail": {
                  "type": "string"
                }
              },
              "required": [
                "label"
              ]
            }
          }
        },
        "required": [
          "id",
          "prompt",
          "kind",
          "choices"
        ]
      },
      "Run": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256,
            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
          },
          "source": {
            "type": "string",
            "enum": [
              "chat",
              "recording"
            ],
            "description": "`recording`: a workflow run a recording started."
          },
          "recordingId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256,
            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
          },
          "status": {
            "type": "string",
            "enum": [
              "running",
              "awaiting_approval",
              "completed",
              "failed",
              "cancelled"
            ]
          },
          "reply": {
            "type": "string",
            "description": "Italic's answer, in Markdown."
          },
          "error": {
            "type": "string"
          },
          "prompt": {
            "type": "string",
            "description": "Chat runs: what was asked."
          },
          "workflows": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 256,
                  "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
                },
                "name": {
                  "type": "string"
                }
              },
              "required": [
                "id",
                "name"
              ]
            }
          },
          "actions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RunAction"
            }
          },
          "questions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Question"
            }
          },
          "createdAt": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "updatedAt": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          }
        },
        "required": [
          "id",
          "source",
          "status",
          "actions",
          "questions",
          "createdAt",
          "updatedAt"
        ]
      },
      "RunAction": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256,
            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
          },
          "tool": {
            "type": "string",
            "description": "What the draft does: send_email, create_event, create_reminder, trash_email, send_webhook, create_notion_page, send_slack_message, save_to_drive, mcp_call and others."
          },
          "status": {
            "type": "string",
            "enum": [
              "proposed",
              "approved",
              "executing",
              "succeeded",
              "failed",
              "rejected",
              "uncertain"
            ],
            "description": "`proposed`: waiting for approval. `approved`: an iPhone adds it (reminders). `uncertain`: it may or may not have happened."
          },
          "executor": {
            "type": "string",
            "enum": [
              "cloud",
              "device"
            ]
          },
          "args": {
            "type": "object",
            "description": "The draft's fields, as the apps' card shows them."
          },
          "result": {
            "type": "object"
          },
          "link": {
            "type": "string",
            "description": "Opens what a finished action made, such as the sent email."
          },
          "workflowId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256,
            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
          }
        },
        "required": [
          "id",
          "tool",
          "status",
          "executor",
          "args"
        ]
      },
      "RunResult": {
        "type": "object",
        "properties": {
          "run": {
            "$ref": "#/components/schemas/Run"
          },
          "replayed": {
            "type": "boolean"
          }
        },
        "required": [
          "run"
        ]
      }
    }
  }
}
```

## Stop a run

`POST https://app.italic.com/api/v2/runs/{id}/cancel`

Required permission: agent:chat. Discards the run's waiting drafts and ends it.

```json
{
  "openapi": "3.1.0",
  "info": {
    "title": "Italic API",
    "version": "2.0.0",
    "description": "Recordings, devices, chat, tasks, workflows, connectors and notifications. Text syncs to Italic; audio stays on the client."
  },
  "servers": [
    {
      "url": "https://app.italic.com/api/v2"
    }
  ],
  "paths": {
    "/runs/{id}/cancel": {
      "post": {
        "operationId": "cancelRun",
        "summary": "Stop a run",
        "tags": [
          "Chat"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256,
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
            }
          }
        ],
        "description": "Required permission: agent:chat. Discards the run's waiting drafts and ends it.",
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success. Writes without read permission return an ID and revision only.",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                },
                "description": "Request identifier for troubleshooting."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RunResult"
                }
              }
            }
          },
          "default": {
            "description": "Request failed. Errors include a stable code and a readable message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "An API key from Settings → Developers → API keys."
      },
      "accountSession": {
        "type": "http",
        "scheme": "bearer",
        "description": "A signed-in Italic account session. An API key cannot create or revoke keys."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "minLength": 0,
                "maxLength": 100
              },
              "message": {
                "type": "string",
                "minLength": 0,
                "maxLength": 1000
              }
            },
            "required": [
              "code",
              "message"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "error"
        ]
      },
      "Question": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256,
            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
          },
          "prompt": {
            "type": "string"
          },
          "about": {
            "type": "string"
          },
          "kind": {
            "type": "string",
            "enum": [
              "recipient",
              "account",
              "text"
            ]
          },
          "choices": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "label": {
                  "type": "string"
                },
                "detail": {
                  "type": "string"
                }
              },
              "required": [
                "label"
              ]
            }
          }
        },
        "required": [
          "id",
          "prompt",
          "kind",
          "choices"
        ]
      },
      "Run": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256,
            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
          },
          "source": {
            "type": "string",
            "enum": [
              "chat",
              "recording"
            ],
            "description": "`recording`: a workflow run a recording started."
          },
          "recordingId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256,
            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
          },
          "status": {
            "type": "string",
            "enum": [
              "running",
              "awaiting_approval",
              "completed",
              "failed",
              "cancelled"
            ]
          },
          "reply": {
            "type": "string",
            "description": "Italic's answer, in Markdown."
          },
          "error": {
            "type": "string"
          },
          "prompt": {
            "type": "string",
            "description": "Chat runs: what was asked."
          },
          "workflows": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 256,
                  "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
                },
                "name": {
                  "type": "string"
                }
              },
              "required": [
                "id",
                "name"
              ]
            }
          },
          "actions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RunAction"
            }
          },
          "questions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Question"
            }
          },
          "createdAt": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "updatedAt": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          }
        },
        "required": [
          "id",
          "source",
          "status",
          "actions",
          "questions",
          "createdAt",
          "updatedAt"
        ]
      },
      "RunAction": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256,
            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
          },
          "tool": {
            "type": "string",
            "description": "What the draft does: send_email, create_event, create_reminder, trash_email, send_webhook, create_notion_page, send_slack_message, save_to_drive, mcp_call and others."
          },
          "status": {
            "type": "string",
            "enum": [
              "proposed",
              "approved",
              "executing",
              "succeeded",
              "failed",
              "rejected",
              "uncertain"
            ],
            "description": "`proposed`: waiting for approval. `approved`: an iPhone adds it (reminders). `uncertain`: it may or may not have happened."
          },
          "executor": {
            "type": "string",
            "enum": [
              "cloud",
              "device"
            ]
          },
          "args": {
            "type": "object",
            "description": "The draft's fields, as the apps' card shows them."
          },
          "result": {
            "type": "object"
          },
          "link": {
            "type": "string",
            "description": "Opens what a finished action made, such as the sent email."
          },
          "workflowId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256,
            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
          }
        },
        "required": [
          "id",
          "tool",
          "status",
          "executor",
          "args"
        ]
      },
      "RunResult": {
        "type": "object",
        "properties": {
          "run": {
            "$ref": "#/components/schemas/Run"
          },
          "replayed": {
            "type": "boolean"
          }
        },
        "required": [
          "run"
        ]
      }
    }
  }
}
```
