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

# Create a hosted session

> Returns the `url` of a page hosted by us, to give to your user (redirect or new window, not an iframe). It expires and serves once. Follow the outcome with `GET /hosted-sessions/{id}` or the webhooks.



## OpenAPI

````yaml /api-reference/v2.0/openapi.json post /hosted-sessions
openapi: 3.1.0
info:
  title: Shortext API
  description: >-
    **Versioning**: every version is a frozen contract. A released version only
    receives additive changes

    (new endpoints, new optional fields, new response fields); anything breaking
    ships in a new version.

    Responses carry `X-Shortext-Api-Version`. When a version is scheduled for
    removal, responses also carry

    `Deprecation` and `Sunset` headers; after the sunset date the version
    answers HTTP 410.

    The list of versions and their status is available at `GET /api/versions`.


    **Responses**: always HTTP 200. Check `success` and `code` (`1000` =
    success), see `ApiEnvelope`.

    On failure, `trace_id` identifies the request for support.
  version: '2.0'
servers:
  - url: https://shortext.ny-corp.io/api/v2.0
security: []
tags:
  - name: Agents
    description: Agents
  - name: Channels
    description: Channels
  - name: Conversations
    description: Conversations
  - name: Account
    description: Account
  - name: Templates
    description: Templates
  - name: Hosted sessions
    description: Hosted sessions
  - name: Webhooks
    description: Webhooks
paths:
  /hosted-sessions:
    post:
      tags:
        - Hosted sessions
      summary: Create a hosted session
      description: >-
        Returns the `url` of a page hosted by us, to give to your user (redirect
        or new window, not an iframe). It expires and serves once. Follow the
        outcome with `GET /hosted-sessions/{id}` or the webhooks.
      operationId: createHostedSession
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/HostedSessionInput'
      responses:
        '200':
          description: >-
            Always HTTP 200: the outcome is in `success` and `code` (absolute
            value of the response code).
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/ApiEnvelope'
                  - properties:
                      body:
                        allOf:
                          - $ref: '#/components/schemas/HostedSession'
                          - properties:
                              url:
                                description: The page to give to your user (holds a secret)
                                type: string
                            type: object
                    type: object
      security:
        - bearerAuth: []
components:
  schemas:
    HostedSessionInput:
      required:
        - purpose
      properties:
        purpose:
          description: GET /hosted-sessions/purposes
          type: string
          example: whatsapp
        context:
          description: Options of the purpose
          type: object
        return_url:
          type:
            - string
            - 'null'
          format: uri
        locale:
          type:
            - string
            - 'null'
          example: fr
        expires_in:
          description: Minutes, default 60
          type: integer
          maximum: 1440
          minimum: 5
      type: object
    ApiEnvelope:
      properties:
        success:
          type: boolean
          example: true
        code:
          type: integer
          example: 1000
        message:
          type: string
          example: Request success.
        body:
          description: Endpoint payload, null when there is none
        token:
          description: Present only on authentication routes
          type:
            - string
            - 'null'
        trace_id:
          description: Present only when success is false
          type:
            - string
            - 'null'
      type: object
    HostedSession:
      description: >-
        A signed, expiring, single-use link to one of our hosted pages, and its
        outcome
      properties:
        id:
          description: Session id
          type: string
          format: uuid
        purpose:
          type: string
          example: whatsapp
        status:
          type: string
          enum:
            - pending
            - opened
            - completed
            - failed
            - cancelled
            - expired
        url:
          description: >-
            Only in the creation response: the page to give to your user. It
            holds a secret, never log or share it.
          type: string
        context:
          type: object
        result:
          description: What the session produced (completed)
          type:
            - object
            - 'null'
        error:
          type:
            - string
            - 'null'
        return_url:
          description: Your page the user is sent back to, with ?session_id=...&status=...
          type:
            - string
            - 'null'
        locale:
          type:
            - string
            - 'null'
        expires_at:
          type: string
          format: date-time
        opened_at:
          type:
            - string
            - 'null'
          format: date-time
        finished_at:
          type:
            - string
            - 'null'
          format: date-time
        created_at:
          type: string
          format: date-time
      type: object
  securitySchemes:
    bearerAuth:
      type: http
      description: >-
        Company API key, sent as `Authorization: Bearer <key>`. Create it in the
        dashboard (Developer > API Keys) with the permissions the integration
        needs.
      scheme: bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.