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

# Create Messages

> Send a message to an individual recipient

### Sending Messages:

* **Group Chats**: The agent's phone number must first be added to the group chat before messages can be sent.

* **Individual Chats**: A user must initiate the conversation with the agent's phone number before the agent can send messages.

**NPM Package**

[**https://www.npmjs.com/package/a1base-api**](https://www.npmjs.com/package/a1base-api)

### Sending Text Messages

```json theme={null}
POST /individual/{accountId}/send
Headers:
  x-api-key: your_api_key
  x-api-secret: your_api_secret
  Content-Type: application/json

Body:
{
  "from": "+14155552671",
  "to": "+14155551234",
  "service": "whatsapp",
  "message": "Hello, this is a test message!"
}
```

### Sending Media Messages

#### Individual Media Message

To send an image to an individual:

```json theme={null}
POST /individual/{accountId}/send
Headers:
  x-api-key: your_api_key
  x-api-secret: your_api_secret
  Content-Type: application/json

Body:
{
  "from": "+14155552671",
  "to": "+14155551234",
  "service": "whatsapp",
  "message_type": "media",
  "media_url": "https://example.com/images/sample.jpg",
  "media_type": "image",
  "caption": "Check out this image!"
}
```

### Using the Universal Endpoint

You can also use the newer universal endpoint for both text and media messages:

```json theme={null}
POST /send/{accountId}
Headers:
  x-api-key: your_api_key
  x-api-secret: your_api_secret
  Content-Type: application/json

Body:
{
  "from": "+14155552671",
  "to": "+14155551234",
  "service": "whatsapp",
  "type": "individual",
  "content": {
    "type": "media",
    "media_url": "https://example.com/videos/demo.mp4",
    "media_type": "video",
    "caption": "Product demo video"
  }
}
```

### Supported Media Types

The API supports these media types:

* **image**: For images (JPG, PNG, etc.)
* **video**: For video files
* **audio**: For audio files
* **document**: For documents (PDF, DOC, etc.)

### Important Notes

* The `media_url` must be a publicly accessible URL where the media file can be downloaded.
* The `caption` field is optional. You can send media without a caption if desired.
* Make sure your media files are in formats supported by WhatsApp.
* There are size limits for different media types:
  * Images: Generally up to 5MB
  * Videos: Generally up to 16MB
  * Audio: Generally up to 16MB
  * Documents: Generally up to 100MB
* The `from` number must be a WhatsApp-enabled number that your account has permission to use.
* The `to` number for individual messages must be a valid WhatsApp number.


## OpenAPI

````yaml POST /messages/individual/{accountId}/send
openapi: 3.1.0
info:
  title: A1Base API
  description: API for sending and receiving messages across messaging platforms
  version: 0.1.0
servers:
  - url: https://api.a1base.com/v1
    description: A1Base API server
  - url: https://your.endpoint.com
    description: Your webhook endpoint
security:
  - apiKeyAuth: []
    apiSecretAuth: []
paths:
  /messages/individual/{accountId}/send:
    post:
      summary: Send Message
      description: Send a message to an individual recipient
      parameters:
        - name: accountId
          in: path
          description: Account ID
          required: true
          schema:
            type: string
        - name: X-API-Key
          in: header
          required: true
          schema:
            type: string
        - name: X-API-Secret
          in: header
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - content
                - from
                - to
                - service
              properties:
                content:
                  type: string
                  description: Message body text
                attachment_uri:
                  type: string
                  description: Optional file/media attachment
                from:
                  type: string
                  description: Sender phone number
                to:
                  type: string
                  description: Recipient phone number
                service:
                  type: string
                  description: Messaging service to use
                  enum:
                    - whatsapp
                    - telegram
      responses:
        '200':
          description: Message sent successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  to:
                    type: string
                  from:
                    type: string
                  body:
                    type: string
                  status:
                    type: string
                    enum:
                      - queued
                      - sent
                  date_created:
                    type: string
                    format: date-time
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationError'
components:
  schemas:
    ValidationError:
      type: object
      properties:
        detail:
          type: array
          items:
            type: object
            properties:
              loc:
                type: array
                items:
                  type:
                    - string
                    - integer
              msg:
                type: string
              type:
                type: string
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
    apiSecretAuth:
      type: apiKey
      in: header
      name: X-API-Secret

````