> ## Documentation Index
> Fetch the complete documentation index at: https://developers.soax.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create stateful sessions

> Create one or more stateful sessions on a package. Each session is bound to a matching exit node before the response returns, so you get its exit IP and connection string straight away.

The `ruleset` is optional: omit it or send `{}` to use the defaults (`lookalike: false`, `rotation_trigger: "timed:300"`, `error_handling: "replace"`). With `count` > 1, each session gets the base `name` plus a number (`job` gives `job1`, `job2`, …).

Node assignment is per session. A session that cannot be bound is discarded, so the response can hold fewer sessions than you asked for: check `failed` and `reason`. If none could be bound, the request fails with `503` and a `Retry-After` header.

Creates for the same package run one at a time; an overlapping create may get `429`.

Requires the `proxy:packages:write` scope.



## OpenAPI

````yaml api/openapi.json POST /v1/proxy/packages/{package_id}/stateful-sessions
openapi: 3.1.0
info:
  title: SOAX API
  version: v1
  description: >-
    Programmatic access to your SOAX account: manage proxy packages, generate
    connection strings, browse available locations, pull usage analytics, and
    manage API keys. All endpoints are served over HTTPS and return JSON.
servers:
  - url: https://api.platform.soax.com
security:
  - bearerAuth: []
tags:
  - name: API Keys
    description: >-
      Self-service management of the API keys used to authenticate with this
      API.
  - name: Packages
    description: >-
      Read proxy packages, build proxy connection strings, and rotate package
      passwords.
  - name: Stateful Sessions
    description: Create and manage long-lived, server-configured proxy sessions.
  - name: Locations
    description: >-
      Location reference data: tiers, countries, regions, cities, ISPs, ASNs,
      and ZIP codes.
  - name: Account
    description: Read-only account, credit, and subscription information.
  - name: Analytics
    description: Usage analytics for your proxy packages.
paths:
  /v1/proxy/packages/{package_id}/stateful-sessions:
    post:
      tags:
        - Stateful Sessions
      summary: Create stateful sessions
      description: >-
        Create one or more stateful sessions on a package. Each session is bound
        to a matching exit node before the response returns, so you get its exit
        IP and connection string straight away.


        The `ruleset` is optional: omit it or send `{}` to use the defaults
        (`lookalike: false`, `rotation_trigger: "timed:300"`, `error_handling:
        "replace"`). With `count` > 1, each session gets the base `name` plus a
        number (`job` gives `job1`, `job2`, …).


        Node assignment is per session. A session that cannot be bound is
        discarded, so the response can hold fewer sessions than you asked for:
        check `failed` and `reason`. If none could be bound, the request fails
        with `503` and a `Retry-After` header.


        Creates for the same package run one at a time; an overlapping create
        may get `429`.


        Requires the `proxy:packages:write` scope.
      operationId: >-
        create_stateful_session_v1_proxy_packages__package_id__stateful_sessions_post
      parameters:
        - name: package_id
          in: path
          required: true
          schema:
            type: string
            pattern: ^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$
            description: The ID of the proxy package (UUID format)
            title: Package Id
          description: The ID of the proxy package (UUID format)
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/StatefulSessionCreateRequest'
            examples:
              single:
                summary: One session in California
                value:
                  name: checkout
                  ruleset:
                    country: us
                    region: california
              batch:
                summary: A pool of 50 sessions with defaults
                value:
                  name: w
                  count: 50
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StatefulSessionCreateResponse'
              example:
                data:
                  - id: 7c1e9a52-3b4d-4f6a-9e8b-2d5c0a1f6b3e
                    proxy_id: b2f0c3d4-e5a6-4b7c-8d9e-0f1a2b3c4d5e
                    name: checkout1
                    status: enabled
                    ruleset:
                      network_type: wifi
                      country: us
                      region: california
                      city: null
                      isp: null
                      asn: null
                      zip: null
                      lookalike: false
                      rotation_trigger: timed:300
                      error_handling: replace
                    exit_ip: 203.0.113.42
                    network_type: wifi
                    country: us
                    region: california
                    city: los_angeles
                    isp: charter_communications
                    asn: '20001'
                    zip: null
                    bound_since: '2026-10-27T10:15:04Z'
                    port: 1337
                    created_at: '2026-10-27T10:15:03Z'
                    updated_at: '2026-10-27T10:15:04Z'
                    connection_string:
                      uri: stateful-checkout1:aB3dE5fG7h@proxy.soax.com:1337
                      username: stateful-checkout1
                      password: aB3dE5fG7h
                      host: proxy.soax.com
                      port: 1337
                failed: 0
                reason: null
        '400':
          description: >-
            Invalid name or ruleset, session limit reached, stateful sessions
            disabled on the package, or the package is suspended.
          content:
            application/json:
              example:
                detail: >-
                  Creating 50 session(s) would exceed limit of 1000. Current:
                  980.
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          description: The API key does not carry the scope this endpoint requires.
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
              example:
                detail: 'Missing required scope: proxy:packages:write'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '429':
          description: >-
            Another create for this package is still in progress, or the API
            key's rate limit was exceeded (5 requests/second per API key, 500
            requests/minute per IP). Wait `Retry-After` seconds where present
            and retry.
          content:
            application/json:
              example:
                detail: Too Many Requests
        '502':
          description: >-
            Every requested session failed with an unexpected error. Nothing was
            created.
          content:
            application/json:
              example:
                detail: >-
                  None of the 1 requested sessions could be assigned a node; no
                  sessions were created.
        '503':
          description: >-
            No exit node matched the ruleset for any requested session. Nothing
            was created. Retry after the `Retry-After` delay, or broaden the
            ruleset.
          content:
            application/json:
              example:
                detail: >-
                  None of the 1 requested sessions could be assigned a node; no
                  sessions were created.
components:
  schemas:
    StatefulSessionCreateRequest:
      properties:
        name:
          anyOf:
            - type: string
            - type: 'null'
          title: Name
          description: >-
            Session name, `^[a-z0-9]{1,16}$`, unique within the package. With
            `count` > 1 it is the base name and each session gets a number
            appended, which counts toward the 16 characters. Omit it and a name
            is generated.
        ruleset:
          $ref: '#/components/schemas/StatefulSessionRequestRulesetSchema'
        count:
          type: integer
          maximum: 1000
          minimum: 1
          title: Count
          default: 1
          description: Number of sessions to create, 1 to 1000.
      type: object
      title: StatefulSessionCreateRequest
    StatefulSessionCreateResponse:
      properties:
        data:
          items:
            $ref: '#/components/schemas/StatefulSessionResponse'
          type: array
          title: Data
        failed:
          type: integer
          title: Failed
        reason:
          anyOf:
            - type: string
            - type: 'null'
          title: Reason
      type: object
      required:
        - data
        - failed
      title: StatefulSessionCreateResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    StatefulSessionRequestRulesetSchema:
      properties:
        network_type:
          anyOf:
            - type: string
              enum:
                - wifi
                - mobile
                - any
            - type: 'null'
          title: Network Type
          description: >-
            `wifi` (residential), `mobile`, or `any`. Must be enabled on the
            package.
        country:
          anyOf:
            - type: string
            - type: 'null'
          title: Country
          description: >-
            Two-letter country code, or `any`. Must be available on the package.
            Required when any of `region`, `city`, `isp`, `asn` or `zip` is set.
        region:
          anyOf:
            - type: string
            - type: 'null'
          title: Region
          description: >-
            Region code from the package location endpoints. Must belong to
            `country`.
        city:
          anyOf:
            - type: string
            - type: 'null'
          title: City
          description: >-
            City code from the package location endpoints. Must belong to
            `region`, or to `country` when no region is set.
        isp:
          anyOf:
            - type: string
            - type: 'null'
          title: Isp
          description: >-
            ISP code from the package location endpoints, valid for the chosen
            country, region and city.
        asn:
          anyOf:
            - type: string
            - type: 'null'
          title: Asn
          description: >-
            ASN from the package location endpoints. Requires ASN targeting on
            your plan.
        zip:
          anyOf:
            - type: string
            - type: 'null'
          title: Zip
          description: >-
            ZIP code from the package location endpoints. Requires ZIP targeting
            on your plan.
        lookalike:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Lookalike
          description: >-
            `true` or `false`: whether a replacement node should resemble the
            previous one (same ISP and location where possible). Defaults to
            `false` on create. Cannot be `true` with `rotation_trigger: "bind"`.
            On update, omit it to keep the stored value; `null` is rejected
            (422).
        rotation_trigger:
          anyOf:
            - type: string
            - type: 'null'
          title: Rotation Trigger
          description: >-
            When the exit node changes: `timed:<seconds>` (minimum 10),
            `request-count:<requests>`, `on-error` (only when the node fails) or
            `bind` (pin the node). Defaults to `timed:300` on create. `bind`
            cannot be combined with `error_handling: "replace"` or `lookalike:
            true`. On update, omit it to keep the stored value; `null` is
            rejected (422).
        error_handling:
          anyOf:
            - type: string
            - type: 'null'
          title: Error Handling
          description: >-
            What happens when the bound node fails: `replace` (switch to a new
            node), `retry_<attempts>` (retry on the same node first) or `fail`
            (return the error). Defaults to `replace` on create, or `retry_3`
            when `rotation_trigger` is `bind`. On update, omit it to keep the
            stored value; `null` is rejected (422).
      type: object
      title: StatefulSessionRequestRulesetSchema
    StatefulSessionResponse:
      properties:
        id:
          type: string
          title: Id
        proxy_id:
          type: string
          title: Proxy Id
        name:
          type: string
          title: Name
        status:
          $ref: '#/components/schemas/StatefulSessionStatus'
          description: '`enabled` or `disabled`.'
        ruleset:
          $ref: '#/components/schemas/StatefulSessionRulesetSchema'
          description: 'The rules you set: what the session is allowed to use.'
        exit_ip:
          type: string
          title: Exit Ip
          description: IP address of the exit node the session is bound to now.
        network_type:
          type: string
          title: Network Type
          description: >-
            Network of the bound node. The top-level geo and network fields
            describe where the session is bound now; `ruleset` holds what you
            asked for.
        country:
          type: string
          title: Country
        region:
          anyOf:
            - type: string
            - type: 'null'
          title: Region
        city:
          anyOf:
            - type: string
            - type: 'null'
          title: City
        isp:
          anyOf:
            - type: string
            - type: 'null'
          title: Isp
        asn:
          anyOf:
            - type: string
            - type: 'null'
          title: Asn
        zip:
          anyOf:
            - type: string
            - type: 'null'
          title: Zip
        bound_since:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Bound Since
          description: When the session was bound to its current node.
        port:
          anyOf:
            - type: integer
            - type: 'null'
          title: Port
          description: >-
            Gateway port to connect to. IP allowlist packages get a dedicated
            port per session; credential packages share the gateway port.
        created_at:
          type: string
          format: date-time
          title: Created At
        updated_at:
          type: string
          format: date-time
          title: Updated At
        connection_string:
          anyOf:
            - $ref: '#/components/schemas/ConnectionStringSchema'
            - type: 'null'
          description: >-
            How to connect. For credential packages the username is
            `stateful-<name>` and the password is the package key. For IP
            allowlist packages `username` and `password` are empty and `uri` is
            `host:port`.
      type: object
      required:
        - id
        - proxy_id
        - name
        - status
        - ruleset
        - exit_ip
        - network_type
        - country
        - created_at
        - updated_at
      title: StatefulSessionResponse
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    StatefulSessionStatus:
      type: string
      enum:
        - enabled
        - disabled
      title: StatefulSessionStatus
    StatefulSessionRulesetSchema:
      properties:
        network_type:
          anyOf:
            - type: string
              enum:
                - wifi
                - mobile
                - any
            - type: 'null'
          title: Network Type
          description: >-
            `wifi` (residential), `mobile`, or `any`. Must be enabled on the
            package.
        country:
          anyOf:
            - type: string
            - type: 'null'
          title: Country
          description: >-
            Two-letter country code, or `any`. Must be available on the package.
            Required when any of `region`, `city`, `isp`, `asn` or `zip` is set.
        region:
          anyOf:
            - type: string
            - type: 'null'
          title: Region
          description: >-
            Region code from the package location endpoints. Must belong to
            `country`.
        city:
          anyOf:
            - type: string
            - type: 'null'
          title: City
          description: >-
            City code from the package location endpoints. Must belong to
            `region`, or to `country` when no region is set.
        isp:
          anyOf:
            - type: string
            - type: 'null'
          title: Isp
          description: >-
            ISP code from the package location endpoints, valid for the chosen
            country, region and city.
        asn:
          anyOf:
            - type: string
            - type: 'null'
          title: Asn
          description: >-
            ASN from the package location endpoints. Requires ASN targeting on
            your plan.
        zip:
          anyOf:
            - type: string
            - type: 'null'
          title: Zip
          description: >-
            ZIP code from the package location endpoints. Requires ZIP targeting
            on your plan.
        lookalike:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Lookalike
          description: Whether a replacement node should resemble the previous one.
        rotation_trigger:
          anyOf:
            - type: string
            - type: 'null'
          title: Rotation Trigger
          description: >-
            `bind`, `on-error`, `timed:<seconds>` (minimum 10) or
            `request-count:<requests>`.
        error_handling:
          anyOf:
            - type: string
            - type: 'null'
          title: Error Handling
          description: '`replace`, `fail` or `retry_<attempts>`.'
      type: object
      title: StatefulSessionRulesetSchema
    ConnectionStringSchema:
      properties:
        uri:
          type: string
          title: Uri
        username:
          type: string
          title: Username
        password:
          anyOf:
            - type: string
            - type: 'null'
          title: Password
        host:
          type: string
          title: Host
        port:
          type: integer
          title: Port
      type: object
      required:
        - uri
        - username
        - host
        - port
      title: ConnectionStringSchema
  responses:
    Unauthorized:
      description: Missing, invalid, or revoked API key.
      content:
        application/json:
          schema:
            type: object
            properties:
              detail:
                type: string
          example:
            detail: Invalid API key
    NotFound:
      description: >-
        The resource does not exist, belongs to another organization, or is
        outside the API key's package restriction.
      content:
        application/json:
          schema:
            type: object
            properties:
              detail:
                type: string
          example:
            detail: Package not found
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        API key secret (starts with `s_live_`). Create keys in the dashboard
        under **Settings → API keys**, or via `POST /v1/api-keys/`. Send it as
        `Authorization: Bearer <secret>`.

````

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