> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.apologist.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.apologist.ai/_mcp/server.

# Twilio SMS/WhatsApp Webhook

POST https://your-agent-domain.com/api/v1/channels/{id}/twilio
Content-Type: application/x-www-form-urlencoded

Receives inbound Twilio messages for the channel as form-encoded data. Payload fields are defined by Twilio.

Reference: https://docs.apologist.ai/agent-api/api-reference/channels/receive-twilio-message

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: agent-api
  version: 1.0.0
paths:
  /channels/{id}/twilio:
    post:
      operationId: receiveTwilioMessage
      summary: Twilio SMS/WhatsApp Webhook
      description: >-
        Receives inbound Twilio messages for the channel as form-encoded data.
        Payload fields are defined by Twilio.
      tags:
        - channels
      parameters:
        - name: id
          in: path
          description: The channel id
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Message handled
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/Channels_receiveTwilioMessage_Response_200
        '403':
          description: Incorrect Twilio credentials
          content:
            application/json:
              schema:
                description: Any type
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                description: Any type
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                From:
                  type: string
                Body:
                  type: string
servers:
  - url: https://your-agent-domain.com/api/v1
    description: Production server
components:
  schemas:
    Channels_receiveTwilioMessage_Response_200:
      type: object
      properties: {}
      description: Empty response body
      title: Channels_receiveTwilioMessage_Response_200

```

## Examples



**Request**

```json
{}
```

**Response**

```json
{}
```

**SDK Code**

```typescript
import { ApologistAgentClient } from "apologist";

async function main() {
    const client = new ApologistAgentClient();
    await client.channels.receiveTwilioMessage("id", {});
}
main();

```

```python
from apologist import ApologistAgent

client = ApologistAgent()

client.channels.receive_twilio_message(
    id="id",
)

```

```java
package com.example.usage;

import ai.apologist.AgentClient;
import ai.apologist.resources.channels.requests.ReceiveTwilioMessageRequest;

public class Example {
    public static void main(String[] args) {
        AgentClient client = AgentClient
            .builder()
            .build();

        client.channels().receiveTwilioMessage(
            "id",
            ReceiveTwilioMessageRequest
                .builder()
                .build()
        );
    }
}
```

```ruby
require "apologist"

client = Apologist::AgentClient.new

client.channels.receive_twilio_message(id: "id")

```

```csharp
using Apologist;
using System.Threading.Tasks;

namespace Usage;

public class Example
{
    public async Task Do() {
        var client = new AgentClient();

        await client.Channels.ReceiveTwilioMessageAsync(
            new ReceiveTwilioMessageRequest {
                Id = "id"
            }
        );
    }

}

```

```go
package example

import (
    context "context"

    apgsdkgo "github.com/apologist-project/apg-sdk-go"
    client "github.com/apologist-project/apg-sdk-go/client"
)

func do() {
    client := client.NewApologistAgentClient()
    request := &apgsdkgo.ReceiveTwilioMessageRequest{
        ID: "id",
    }
    client.Channels.ReceiveTwilioMessage(
        context.TODO(),
        request,
    )
}

```

```php
<?php

namespace Example;

use Apologist\AgentClient;
use Apologist\Channels\Requests\ReceiveTwilioMessageRequest;

$client = new AgentClient();
$client->channels->receiveTwilioMessage(
    'id',
    new ReceiveTwilioMessageRequest([]),
);

```

```swift
import Foundation

let headers = ["Content-Type": "application/x-www-form-urlencoded"]

let request = NSMutableURLRequest(url: NSURL(string: "https://your-agent-domain.com/api/v1/channels/id/twilio")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```