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

# Ensure the proxy's upstream session works

> Checks right now that the proxy's upstream accepts a connection through its current session. If the upstream refuses the session and the proxy is a rotating (sticky-session) proxy, the proxy is moved onto a fresh session that has been checked to work; its credentials and country stay the same, its exit IP changes. Intended for callers that are about to depend on the proxy (e.g. while provisioning a phone). After `rotated`, the gateway uses the new session within about 30 seconds. A `refused` or `unreachable` result is not an error: the response describes the proxy's state.



## OpenAPI

````yaml /api-reference/mobilerun-proxy/proxies.yaml post /connect/proxies/{id}/ensure-healthy
openapi: 3.1.0
info:
  title: Proxies
  version: v1
servers:
  - description: Droidrun Cloud API
    url: https://api.mobilerun.ai/v1
security:
  - bearerAuth: []
paths:
  /connect/proxies/{id}/ensure-healthy:
    post:
      tags:
        - Proxies
      summary: Ensure the proxy's upstream session works
      description: >-
        Checks right now that the proxy's upstream accepts a connection through
        its current session. If the upstream refuses the session and the proxy
        is a rotating (sticky-session) proxy, the proxy is moved onto a fresh
        session that has been checked to work; its credentials and country stay
        the same, its exit IP changes. Intended for callers that are about to
        depend on the proxy (e.g. while provisioning a phone). After `rotated`,
        the gateway uses the new session within about 30 seconds. A `refused` or
        `unreachable` result is not an error: the response describes the proxy's
        state.
      operationId: EnsureProxyHealthy
      parameters:
        - $ref: '#/components/parameters/ProxyID'
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProxyHealth'
          description: The result of the check.
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import Mobilerun from '@mobilerun/sdk';


            const client = new Mobilerun({
              apiKey: process.env['MOBILERUN_CLOUD_API_KEY'], // This is the default and can be omitted
            });


            const response = await
            client.connect.proxies.ensureHealthy('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e');


            console.log(response.proxyId);
        - lang: Python
          source: |-
            import os
            from mobilerun_sdk import Mobilerun

            client = Mobilerun(
                api_key=os.environ.get("MOBILERUN_CLOUD_API_KEY"),  # This is the default and can be omitted
            )
            response = client.connect.proxies.ensure_healthy(
                "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
            )
            print(response.proxy_id)
components:
  parameters:
    ProxyID:
      in: path
      name: id
      required: true
      schema:
        format: uuid
        type: string
  schemas:
    ProxyHealth:
      description: The outcome of an ensure-healthy check.
      properties:
        proxyId:
          format: uuid
          type: string
        status:
          description: >-
            `healthy`: the upstream accepted the current session. `rotated`: the
            session was refused and the proxy now uses a fresh, checked session;
            retry through the proxy. `refused`: the session was refused and
            could not be replaced. `unreachable`: the upstream could not be
            reached; the session was left unchanged.
          enum:
            - healthy
            - rotated
            - refused
            - unreachable
          type: string
      required:
        - proxyId
        - status
      type: object
    ConnectErrorResponse:
      description: A Problem Details (RFC 7807-style) error response.
      properties:
        detail:
          description: Human-readable explanation of this occurrence.
          type: string
        errors:
          description: Per-input errors, when applicable.
          items:
            $ref: '#/components/schemas/ConnectErrorDetail'
          type: array
        status:
          description: HTTP status code.
          type: integer
        title:
          description: Short, human-readable summary of the error type.
          type: string
      required:
        - title
        - status
        - detail
        - errors
      type: object
    ConnectErrorDetail:
      description: A single error, locating an offending input where applicable.
      properties:
        location:
          description: Path to the offending input, e.g. "body.proxyId".
          type: string
        message:
          description: Human-readable description of this error.
          type: string
        value:
          description: The offending value, when available.
      required:
        - location
        - message
      type: object
  responses:
    Unauthorized:
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/ConnectErrorResponse'
      description: Missing or invalid credentials.
    NotFound:
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/ConnectErrorResponse'
      description: The resource was not found.
    Conflict:
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/ConnectErrorResponse'
      description: >-
        The request cannot be fulfilled in the current state (e.g. no capacity
        is available for the requested country/type).
  securitySchemes:
    bearerAuth:
      bearerFormat: Opaque
      description: Bearer token via Authorization header
      scheme: bearer
      type: http

````

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