Create a new Session

POST /v1/Services/{ServiceSid}/Sessions

TODO: Resource-level docs

Create a new Session

Path parameters

application/x-www-form-urlencoded

Body

  • DateExpiry string(date-time)

    The ISO 8601 date when the Session should expire. If this is value is present, it overrides the ttl value.

  • [Experimental] For accounts with the ProxyAllowParticipantConflict account flag, setting to true enables per-request opt-in to allowing Proxy to reject a Session create (with Participants) request that could cause the same Identifier/ProxyIdentifier pair to be active in multiple Sessions. Depending on the context, this could be a 409 error (Twilio error code 80623) or a 400 error (Twilio error code 80604). If not provided, requests will be allowed to succeed and a Debugger notification (80802) will be emitted. Having multiple, active Participants with the same Identifier/ProxyIdentifier pair causes calls and messages from affected Participants to be routed incorrectly. Please note, the default behavior for accounts without the ProxyAllowParticipantConflict flag is to reject the request as described. This will eventually be the default for all accounts.

  • Mode string

    The Mode of the Session. Can be: message-only, voice-only, or voice-and-message and the default value is voice-and-message.

    Values are message-only, voice-only, or voice-and-message.

  • The Participant objects to include in the new session.

  • Status string

    The initial status of the Session. Can be: open, in-progress, closed, failed, or unknown. The default is open on create.

    Values are open, in-progress, closed, failed, or unknown.

  • Ttl integer

    The time, in seconds, when the session will expire. The time is measured from the last Session create or the Session's last Interaction.

  • An application-defined string that uniquely identifies the resource. This value must be 191 characters or fewer in length and be unique. This value should not have PII.

Responses

  • 201

    Created

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

      The SID of the Account that created the resource

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

    • closed_reason string | null

      The reason the Session ended

    • date_created string(date-time) | null

      The ISO 8601 date and time in GMT when the resource was created

    • date_ended string(date-time) | null

      The ISO 8601 date when the Session ended

    • date_expiry string(date-time) | null

      The ISO 8601 date when the Session should expire

    • date_last_interaction string(date-time) | null

      The ISO 8601 date when the Session last had an interaction

    • date_started string(date-time) | null

      The ISO 8601 date when the Session started

    • date_updated string(date-time) | null

      The ISO 8601 date and time in GMT when the resource was last updated

    • mode string | null

      The Mode of the Session

      Values are message-only, voice-only, or voice-and-message.

    • service_sid string | null

      The SID of the resource's parent Service

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

    • sid string | null

      The unique string that identifies the resource

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

    • status string | null

      The status of the Session

      Values are open, in-progress, closed, failed, or unknown.

    • ttl integer | null

      When the session will expire

    • unique_name string | null

      An application-defined string that uniquely identifies the resource

    • url string(uri) | null

      The absolute URL of the Session resource

POST /v1/Services/{ServiceSid}/Sessions
curl \
 -X POST https://proxy.twilio.com/v1/Services/{ServiceSid}/Sessions \
 --user "username:password" \
 -H "Content-Type: application/x-www-form-urlencoded" \
 -d 'DateExpiry=2023-05-04T09%3A42%3A00%2B00%3A00&FailOnParticipantConflict=true&Mode=message-only&&Status=open&Ttl=42&UniqueName=string'
Request example
{
  "DateExpiry": "2023-05-04T09:42:00+00:00",
  "FailOnParticipantConflict": true,
  "Mode": "message-only",
  "Participants": [],
  "Status": "open",
  "Ttl": 42,
  "UniqueName": "string"
}
Response examples (201)
{
  "account_sid": "string",
  "closed_reason": "string",
  "date_created": "2023-05-04T09:42:00+00:00",
  "date_ended": "2023-05-04T09:42:00+00:00",
  "date_expiry": "2023-05-04T09:42:00+00:00",
  "date_last_interaction": "2023-05-04T09:42:00+00:00",
  "date_started": "2023-05-04T09:42:00+00:00",
  "date_updated": "2023-05-04T09:42:00+00:00",
  "links": {},
  "mode": "message-only",
  "service_sid": "string",
  "sid": "string",
  "status": "open",
  "ttl": 42,
  "unique_name": "string",
  "url": "https://example.com"
}