> ## 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 Group Messages

> Send a message to a group chat

### Sending Group Messages:

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

* You'll need the thread\_id of the group chat to send messages. This is provided when you create a group or in webhook events.

### Example Request

#### Text Message to Group

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

Body:
{
  "from": "+14155552671",
  "thread_id": "group-thread-id-123",
  "service": "whatsapp",
  "message": "Hello everyone in the group!"
}
```

#### Media Message to Group

To send a document to a group:

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

Body:
{
  "from": "+14155552671",
  "thread_id": "group-thread-id-123",
  "service": "whatsapp",
  "message_type": "media",
  "media_url": "https://example.com/documents/report.pdf",
  "media_type": "document",
  "caption": "Here's the quarterly report"
}
```

### Using the Universal Endpoint for Groups

You can also use the newer universal endpoint for group 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",
  "thread_id": "group-thread-id-123",
  "service": "whatsapp",
  "type": "group",
  "content": {
    "type": "media",
    "media_url": "https://example.com/videos/demo.mp4",
    "media_type": "video",
    "caption": "Product demo video for the team"
  }
}
```

### Important Notes for Group Media Messages

* For group messages, you need a valid `thread_id` instead of a `to` number.
* The `caption` field is optional. You can send media without a caption if desired.
* The same media type and size restrictions apply as with individual messages:
  * Images: Generally up to 5MB
  * Videos: Generally up to 16MB
  * Audio: Generally up to 16MB
  * Documents: Generally up to 100MB
* The agent must be a member of the group before sending messages.


## OpenAPI

````yaml POST /messages/group/{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/group/{accountId}/send:
    post:
      summary: Send Group Message
      description: Send a message to a group chat
      parameters:
        - name: accountId
          in: path
          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
                - thread_id
                - service
                - from
              properties:
                content:
                  type: string
                  description: Message body text
                attachment_uri:
                  type: string
                  description: Optional file/media attachment
                from:
                  type: string
                  description: Sender phone number
                thread_id:
                  type: string
                  description: ID of the chat thread
                service:
                  type: string
                  description: Messaging service to use
                  enum:
                    - whatsapp
                    - telegram
      responses:
        '200':
          description: Message sent successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  chat_group_id:
                    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

````