> ## 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.

# Change a network policy

> Change a network policy, and every running session that uses it. Send one request and get JSON back. Examples in cURL, TypeScript and Python.

## Price

Free.

See [Pricing](https://docs.stophy.dev/account/pricing.md).

```bash cURL theme={null}
curl -X PATCH https://api.stophy.dev/v1/browser/network-policies/3b278838-610e-4e91-9a6c-c627d3a46e63 \
  -H "Authorization: Bearer $STOPHY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"docs-example-renamed"}'
```

```typescript TypeScript theme={null}
const response = await fetch("https://api.stophy.dev/v1/browser/network-policies/3b278838-610e-4e91-9a6c-c627d3a46e63", {
  method: "PATCH",
  headers: {
    Authorization: `Bearer ${process.env.STOPHY_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ name: "docs-example-renamed" }),
});
console.log(await response.json());
```

```python Python theme={null}
import os

import requests

response = requests.patch(
    "https://api.stophy.dev/v1/browser/network-policies/3b278838-610e-4e91-9a6c-c627d3a46e63",
    headers={"Authorization": f"Bearer {os.environ['STOPHY_API_KEY']}"},
    json={"name": "docs-example-renamed"},
)
print(response.json())
```

```json 200 theme={null}
{
  "success": true,
  "id": "3b278838-610e-4e91-9a6c-c627d3a46e63",
  "name": "docs-example-renamed",
  "defaultAction": "block",
  "allow": {
    "domains": [
      "bun.com"
    ]
  },
  "block": {
    "domains": []
  },
  "version": 2,
  "createdAt": "2026-11-17T17:49:05.858Z",
  "updatedAt": "2026-11-17T17:49:06.327Z",
  "runningSessions": 0,
  "appliedSessions": 0,
  "pendingSessionIds": [],
  "closedConnections": 0,
  "costUsd": 0,
  "creditsUsed": 0,
  "requestId": "b79921f7-7a8b-4d84-95b3-bee0b8a2184a"
}
```


## OpenAPI

````yaml api-reference/openapi.json PATCH /v1/browser/network-policies/{policy_id}
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.


    x-cost-usd is what one call costs, in dollars. Every call costs the same,
    whatever it returns, unless an operation's description says it costs per 10
    results, or per hour of audio. Then x-cost-usd is the lowest price and
    x-cost-usd-max the most one call can cost. Where an operation takes limit,
    send it to return fewer results and pay for fewer.


    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/network-policies/{policy_id}:
    patch:
      summary: Change a network policy, and every running session that uses it.
      description: >-
        Free. Each field you send replaces the old one, and a list replaces the
        whole list. The version goes up by 1. Running sessions that use the
        policy pick the change up before this call answers, and they close their
        open connections to hosts the change now blocks. A session this call
        could not reach is listed in pendingSessionIds, and the change is
        retried every few seconds until it reaches it. A session shows the
        version it enforces in networkPolicyVersion. Answers 404 for an unknown
        policy and 400 for a bad body.
      operationId: browserNetworkPolicyUpdate
      parameters:
        - name: policy_id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  minLength: 1
                  maxLength: 100
                defaultAction:
                  type: string
                  enum:
                    - allow
                    - block
                allow:
                  type: object
                  properties:
                    domains:
                      type: array
                      items:
                        type: string
                      maxItems: 10000
                  required:
                    - domains
                  additionalProperties: false
                block:
                  type: object
                  properties:
                    domains:
                      type: array
                      items:
                        type: string
                      maxItems: 10000
                  required:
                    - domains
                  additionalProperties: false
              additionalProperties: false
      responses:
        '200':
          description: The policy.
          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
                  id:
                    type: string
                    format: uuid
                  name:
                    type: string
                  defaultAction:
                    type: string
                    enum:
                      - allow
                      - block
                    description: What happens to a domain that no list entry matches.
                  allow:
                    type: object
                    properties:
                      domains:
                        type: array
                        items:
                          type: string
                        maxItems: 10000
                  block:
                    type: object
                    properties:
                      domains:
                        type: array
                        items:
                          type: string
                        maxItems: 10000
                  version:
                    type: integer
                    description: Starts at 1 and goes up by 1 with each update.
                  createdAt:
                    type: string
                    format: date-time
                  updatedAt:
                    type: string
                    format: date-time
                  runningSessions:
                    type: integer
                    description: >-
                      Running browser sessions that use the policy, applied or
                      pending.
                  appliedSessions:
                    type: integer
                    description: >-
                      How many of them now enforce this version. A session that
                      is still on an older version shows that in
                      networkPolicyVersion.
                  pendingSessionIds:
                    type: array
                    items:
                      type: string
                    description: >-
                      Sessions this call could not reach yet. They still enforce
                      an older version.
                  closedConnections:
                    type: integer
                    description: >-
                      Open connections to hosts the new version blocks, closed
                      in those sessions.
                  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.