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

# Run code or a prompt

> Run code or a prompt in an open browser session.

```bash cURL theme={null}
curl -X POST https://api.stophy.dev/v1/browser/6bd8981c-f2a8-403c-b188-352828c08bc2/execute \
  -H "Authorization: Bearer $STOPHY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"code":"await page.goto('\''https://example.com'\''); console.log(await page.title())","language":"node"}'
```

```json 200 theme={null}
{
  "success": true,
  "output": "Example Domain\n",
  "stdout": "Example Domain\n",
  "stderr": "",
  "exitCode": 0,
  "killed": false,
  "truncated": false,
  "cdpUrl": "<cdpUrl>",
  "liveViewUrl": "<liveViewUrl>",
  "interactiveLiveViewUrl": "<interactiveLiveViewUrl>",
  "costUsd": 0,
  "requestId": "3f3aceae-4b2c-4ae2-bb61-339063f09b60"
}
```


## OpenAPI

````yaml api-reference/openapi.json POST /v1/browser/{session_id}/execute
openapi: 3.1.0
info:
  title: Stophy API
  version: '1'
  description: >-
    Each operation shows its method and its input: a JSON object body, path and
    query parameters, or a file upload.


    Responses leave out empty values: null, empty strings, empty objects and
    empty nested lists are not sent.


    Text comes back whole. To get shorter responses, add
    ?maxTextLength=<characters> to the URL. Every text value longer than that is
    cut and ends with …. A screenshot is never cut, and a page whose text was
    cut has isTruncated set to true.


    The x-cost-usd response header is what the request cost in dollars. An
    operation's description gives its pricing units and add-ons. The OpenAPI
    fields x-cost-usd and x-cost-usd-max are list-price estimates, not receipts
    or spending limits. When a call starts a job, check the job result for its
    total cost.


    When a response has a cursor, send it back unchanged with the same input to
    get the next page. When it has a page, send the next page number.
servers:
  - url: https://api.stophy.dev
security:
  - apiKey: []
paths:
  /v1/browser/{session_id}/execute:
    post:
      summary: Run code or a prompt in an open browser session.
      description: >-
        Send code or a prompt. timeout is in seconds, up to 300, and the
        session's own end still stops the run.
      operationId: browserExecute
      parameters:
        - name: session_id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                code:
                  type: string
                  minLength: 1
                  maxLength: 200000
                prompt:
                  type: string
                  minLength: 1
                  maxLength: 10000
                language:
                  default: node
                  type: string
                  enum:
                    - node
                    - python
                    - bash
                timeout:
                  type: integer
                  minimum: 1
                  maximum: 300
      responses:
        '200':
          description: What the run printed and returned.
          headers:
            X-Request-ID:
              $ref: '#/components/headers/RequestId'
            X-RateLimit-Limit:
              $ref: '#/components/headers/RateLimitLimit'
            X-RateLimit-Remaining:
              $ref: '#/components/headers/RateLimitRemaining'
            X-RateLimit-Reset:
              $ref: '#/components/headers/RateLimitReset'
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                  - costUsd
                  - creditsUsed
                  - requestId
                properties:
                  success:
                    const: true
                  output:
                    type: string
                    description: What the code printed.
                  stdout:
                    type: string
                  result:
                    type: string
                    description: The value the code returned, as text.
                  stderr:
                    type: string
                  exitCode:
                    type: integer
                  killed:
                    type: boolean
                    description: true when the code ran out of time.
                  truncated:
                    type: boolean
                    description: >-
                      True when standard output contains a notice that it was
                      cut. A large returned result can be dropped without
                      setting this flag.
                  error:
                    type: string
                  steps:
                    type: array
                    items:
                      type: string
                  page:
                    type: object
                    properties:
                      url:
                        type: string
                      title:
                        type: string
                  cdpUrl:
                    type: string
                    description: Connect a CDP client such as Playwright here.
                  liveViewUrl:
                    type: string
                    description: Watch the session. Sent with streamWebView.
                  interactiveLiveViewUrl:
                    type: string
                    description: Watch and control the session. Sent with streamWebView.
                  creditsUsed:
                    type: integer
                  costUsd:
                    type: number
                    description: What this call cost, in dollars.
                  requestId:
                    type: string
        4XX:
          $ref: '#/components/responses/Error'
        5XX:
          $ref: '#/components/responses/Error'
components:
  headers:
    RequestId:
      description: The request id. Quote it when you report a problem.
      schema:
        type: string
    RateLimitLimit:
      description: Requests allowed in the current window.
      schema:
        type: integer
    RateLimitRemaining:
      description: Requests left in the current window.
      schema:
        type: integer
    RateLimitReset:
      description: Unix time in seconds when the current window resets.
      schema:
        type: integer
    RetryAfter:
      description: Seconds to wait before retrying.
      schema:
        type: integer
  responses:
    Error:
      description: The request failed. Retry-After says when trying again can help.
      headers:
        X-Request-ID:
          $ref: '#/components/headers/RequestId'
        Retry-After:
          $ref: '#/components/headers/RetryAfter'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    Error:
      type: object
      required:
        - success
        - error
        - code
      properties:
        success:
          const: false
        error:
          type: string
          description: What went wrong and what to do next.
        code:
          type: string
          enum:
            - apiKeyRequired
            - busy
            - checkRunning
            - cliSessionCompleted
            - cliSessionExists
            - cliSessionNotFound
            - forbidden
            - freeLimit
            - insufficientCredits
            - internalError
            - inviteClaimed
            - inviteDisabled
            - inviteExpired
            - inviteUsedUp
            - invalidCliSession
            - invalidCliVerifier
            - invalidRequest
            - jobFinished
            - methodNotAllowed
            - notFound
            - payloadTooLarge
            - profileBusy
            - profileTooLarge
            - prohibitedPermission
            - promptInjectionDetected
            - rateLimited
            - sourceChanged
            - sourceRefused
            - siteNotRead
            - sourceTimeout
            - sourceUnavailable
            - unauthorized
            - unsupportedMediaType
        retryable:
          type: boolean
          description: true when trying again can help.
        retryAfterSeconds:
          type: integer
        requestId:
          type: string
        requiredCredits:
          type: number
          description: >-
            Older field: the most the call can cost, in $0.002 steps. Sent when
            the balance is too low.
        availableCredits:
          type: number
          description: 'Older field: the balance in $0.002 steps. Sent with requiredCredits.'
        requiredUsd:
          type: number
          description: >-
            The most the call can cost, in dollars. Sent when the balance is too
            low.
        availableUsd:
          type: number
          description: What is left on the account, in dollars. Sent with requiredUsd.
        billingUrl:
          type: string
          description: Where to add money. Sent with requiredUsd.
        signupUrl:
          type: string
          const: https://stophy.dev/signup
          description: >-
            Where a person gets a key. Sent with apiKeyRequired, freeLimit and
            an invalid key.
        signup:
          type: string
          const: POST https://api.stophy.dev/v1/signup
          description: >-
            The call that gets an agent a key with no human. Sent next to
            signupUrl.
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer

````

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