Create a new webhook scoped to the conversation in a specific service

POST /v1/Services/{ChatServiceSid}/Conversations/{ConversationSid}/Webhooks

A Conversation-scoped Webhook resource manages a set of callback URLs and their configuration for receiving events specific to one conversation.

Create a new webhook scoped to the conversation in a specific service

Path parameters

  • ChatServiceSid string Required

    The SID of the Conversation Service the Participant resource is associated with.

    Minimum length is 34, maximum length is 34. Format should match the following pattern: ^IS[0-9a-fA-F]{32}$.

  • ConversationSid string Required

    The unique ID of the Conversation for this webhook.

application/x-www-form-urlencoded

Body

  • Target string Required

    The target of this webhook: webhook, studio, trigger

    Values are webhook, trigger, or studio.

  • Configuration.Url string

    The absolute url the webhook request should be sent to.

  • Configuration.Method string

    Values are get or post.

  • Configuration.Filters array[string]

    The list of events, firing webhook event for this Conversation.

  • Configuration.Triggers array[string]

    The list of keywords, firing webhook event for this Conversation.

  • Configuration.FlowSid string

    The studio flow SID, where the webhook should be sent to.

    Minimum length is 34, maximum length is 34. Format should match the following pattern: ^FW[0-9a-fA-F]{32}$.

  • Configuration.ReplayAfter integer

    The message index for which and it's successors the webhook will be replayed. Not set by default

Responses

  • 201 application/json

    Created

    Hide headers attributes Show headers attributes
    • Access-Control-Allow-Origin string

      Specify the origin(s) allowed to access the resource

    • Access-Control-Allow-Methods string

      Specify the HTTP methods allowed when accessing the resource

    • Access-Control-Allow-Headers string

      Specify the headers allowed when accessing the resource

    • Access-Control-Allow-Credentials boolean

      Indicates whether the browser should include credentials

    • Access-Control-Expose-Headers string

      Headers exposed to the client

    Hide response attributes Show response attributes object
    • sid string | null

      A 34 character string that uniquely identifies this resource.

      Minimum length is 34, maximum length is 34. Format should match the following pattern: ^WH[0-9a-fA-F]{32}$.

    • account_sid string | null

      The unique ID of the Account responsible for this conversation.

      Minimum length is 34, maximum length is 34. Format should match the following pattern: ^AC[0-9a-fA-F]{32}$.

    • chat_service_sid string | null

      The SID of the Conversation Service the Participant resource is associated with.

      Minimum length is 34, maximum length is 34. Format should match the following pattern: ^IS[0-9a-fA-F]{32}$.

    • conversation_sid string | null

      The unique ID of the Conversation for this webhook.

      Minimum length is 34, maximum length is 34. Format should match the following pattern: ^CH[0-9a-fA-F]{32}$.

    • target string | null

      The target of this webhook: webhook, studio, trigger

    • url string(uri) | null

      An absolute API resource URL for this webhook.

    • configuration

      The configuration of this webhook. Is defined based on target.

    • date_created string(date-time) | null

      The date that this resource was created.

    • date_updated string(date-time) | null

      The date that this resource was last updated.

POST /v1/Services/{ChatServiceSid}/Conversations/{ConversationSid}/Webhooks
curl \
 --request POST 'https://conversations.twilio.com/v1/Services/{ChatServiceSid}/Conversations/{ConversationSid}/Webhooks' \
 --user "username:password" \
 --header "Content-Type: application/x-www-form-urlencoded" \
 --data 'Target=webhook&Configuration.Url=https%3A%2F%2Fexample.com&Configuration.Method=get&Configuration.Filters=onMessageSent&Configuration.Filters=onConversationDestroyed&Configuration.ReplayAfter=7'
Request example
{"Target"=>"webhook", "Configuration.Url"=>"https://example.com", "Configuration.Method"=>"get", "Configuration.Filters"=>["onMessageSent", "onConversationDestroyed"], "Configuration.ReplayAfter"=>7}
Response examples (201)
{
  "sid": "WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "url": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Webhooks/WHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "target": "webhook",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "date_created": "2016-03-24T21:05:50Z",
  "date_updated": "2016-03-24T21:05:50Z",
  "configuration": {
    "url": "https://example.com",
    "method": "get",
    "filters": [
      "onMessageSent",
      "onConversationDestroyed"
    ]
  },
  "chat_service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "conversation_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}