> ## Documentation Index
> Fetch the complete documentation index at: https://docs.keebai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# POST /v1/crm/notes

> Log a note, call, email, or meeting against a contact or a ticket.

Creates a note. Besides `content`, you must attach the note to something: **at least one of `chat_user` or `ticket_id` is required**. Sending neither returns `400`.

The `company`, `project`, and the note's author are taken from your token and must **not** appear in the body. Sending them returns `400`.

<Tip>
  The author is recorded as the user who owns the token. If several systems write notes, mint one token per system so the timeline shows who wrote what.
</Tip>

## Endpoint

```
POST https://api.keebai.com/v1/crm/notes
```

## Required scope

`crm:notes:write`

## Headers

| Header          | Required | Value                    |
| --------------- | -------- | ------------------------ |
| `Authorization` | Yes      | `Bearer kbai_pk_<token>` |
| `Content-Type`  | Yes      | `application/json`       |

## Body

| Field       | Type     | Required    | Description                                                                           |
| ----------- | -------- | ----------- | ------------------------------------------------------------------------------------- |
| `content`   | `string` | Yes         | The note text. Up to 5000 characters.                                                 |
| `chat_user` | `string` | Conditional | `ObjectId` of the contact the note refers to. Required unless you send `ticket_id`.   |
| `ticket_id` | `string` | Conditional | `ObjectId` of the ticket to attach the note to. Required unless you send `chat_user`. |
| `type`      | `string` | No          | One of `note`, `call`, `email`, `meeting`. Defaults to `note`.                        |

## Example request

<CodeGroup>
  ```bash curl theme={null}
  curl -X POST https://api.keebai.com/v1/crm/notes \
    -H "Authorization: Bearer kbai_pk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
    -H "Content-Type: application/json" \
    -d '{
      "content": "Llamé al cliente, quedó de confirmar el lunes.",
      "ticket_id": "65f4b5c6d7e8f9a0b1c2d3e4",
      "chat_user": "66c1d2e3f4a5b6c7d8e9f0a1",
      "type": "call"
    }'
  ```

  ```js JavaScript theme={null}
  const response = await fetch("https://api.keebai.com/v1/crm/notes", {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.KEEBAI_API_TOKEN}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      content: "Llamé al cliente, quedó de confirmar el lunes.",
      ticket_id: ticketId,
      type: "call",
    }),
  });
  const { note } = await response.json();
  ```

  ```python Python theme={null}
  import os, requests

  resp = requests.post(
      "https://api.keebai.com/v1/crm/notes",
      headers={"Authorization": f"Bearer {os.environ['KEEBAI_API_TOKEN']}"},
      json={
          "content": "Llamé al cliente, quedó de confirmar el lunes.",
          "ticket_id": ticket_id,
          "type": "call",
      },
      timeout=10,
  )
  resp.raise_for_status()
  note = resp.json()["note"]
  ```
</CodeGroup>

## Response

### 201 Created

```json theme={null}
{
  "note": {
    "_id": "65a1f2b3c4d5e6f7a8b9c0d1",
    "chat_user": "66c1d2e3f4a5b6c7d8e9f0a1",
    "ticket_id": "65f4b5c6d7e8f9a0b1c2d3e4",
    "content": "Llamé al cliente, quedó de confirmar el lunes.",
    "type": "call",
    "created_by": "68e1f2a3b4c5d6e7f8a9b0c1",
    "created_at": "2026-05-02T14:31:07.221Z",
    "updated_at": "2026-05-02T14:31:07.221Z"
  }
}
```

### 400 Bad Request

Missing or empty `content`, neither `chat_user` nor `ticket_id`, content longer than 5000 characters, a malformed `ObjectId`, a `type` outside the allowed set, or a property the endpoint does not accept — including `company`, `project`, and `created_by`, which are derived from the token.

### 401 Unauthorized

Missing, invalid, revoked, or expired token.

### 403 Forbidden

The token does not have the `crm:notes:write` scope.

## Operational notes

* **Referenced ids are not verified.** A `ticket_id` pointing at a ticket that does not exist is stored as-is, and the note simply never appears on a timeline. Create the ticket first.
* **Use `type` deliberately.** `call`, `email`, and `meeting` render as interaction entries in the portal; `note` renders as a plain comment.


## OpenAPI

````yaml POST /v1/crm/notes
openapi: 3.0.0
info:
  title: Keebai Public API
  description: Superficie pública REST autenticada con Personal Access Tokens (PAT).
  version: 1.0.0
  contact: {}
servers:
  - url: https://api.keebai.com
    description: Production
security: []
tags: []
paths:
  /v1/crm/notes:
    post:
      tags:
        - crm-notes
      summary: Crear una nota
      description: >-
        La company, el project y el autor se toman del token; enviarlos en el
        body devuelve 400.
      operationId: PublicNotesController_create
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PublicNoteCreateDto'
      responses:
        '201':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicNoteEnvelopeDto'
      security:
        - PAT: []
components:
  schemas:
    PublicNoteCreateDto:
      type: object
      properties:
        content:
          type: string
          description: Contenido de la nota
        chat_user:
          type: string
          description: Chat user (contacto) al que refiere
        ticket_id:
          type: string
          description: Ticket al que se adjunta la nota
        type:
          type: string
          enum:
            - note
            - call
            - email
            - meeting
          default: note
      required:
        - content
    PublicNoteEnvelopeDto:
      type: object
      properties:
        note:
          $ref: '#/components/schemas/PublicNoteResponseDto'
      required:
        - note
    PublicNoteResponseDto:
      type: object
      properties:
        _id:
          type: string
          description: ObjectId de la nota
        content:
          type: string
        type:
          type: string
          enum:
            - note
            - call
            - email
            - meeting
        chat_user:
          type: string
          description: ObjectId del chat user (contacto)
        ticket_id:
          type: string
          description: ObjectId del ticket asociado
        created_by:
          type: string
          description: ObjectId del usuario que creó la nota
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
      required:
        - _id
        - content
        - type
        - created_by
        - created_at
        - updated_at
  securitySchemes:
    PAT:
      scheme: bearer
      bearerFormat: kbai_pk_<hex>
      type: http
      description: >-
        Personal Access Token con prefijo `kbai_pk_`. Generar desde el portal
        con permiso `developer.manage_tokens`.

````