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

# Update a setup script

> ### Overview

Updates a setup script. Send `name`, `type` and the full `content`, even if only one changes. Servers previously configured with the script are not changed.

### Permissions

Requires the `script.update` (Manage setup scripts) permission for the selected team. Resources outside that team return 404.



## OpenAPI

````yaml https://console.advinservers.com/docs/openapi.json patch /user-scripts/{userScript}
openapi: 3.1.0
info:
  title: API reference
  version: 1.0.0
  description: >-
    Use this API to manage your team's servers, networks, backups, and other
    resources.


    ## Authentication


    Create an API key under **API Keys** and send it as a bearer token with
    every request:


    ```

    Authorization: Bearer {YOUR_API_KEY}

    Accept: application/json

    ```


    Copy the key when you create it. It cannot be shown again. Revoking a key
    takes effect immediately.


    ## Permissions


    Give each key only the permissions it needs. Every endpoint lists the
    required permission.


    Permissions cover servers and other resources in the key's team.


    ## Team scope


    A key can access resources in the team selected when it was created. This
    includes servers,

    snapshots, backups, firewall groups, images, SSH keys, scripts, networks and
    addresses.

    Resources in other teams return `404 Not Found`. Create a separate key for
    each team.


    The key determines the team for every request. Legacy keys that had no team
    are assigned

    to the account's first owned team.


    ## Actions that need the panel


    API keys cannot do the following, even with every permission. Sign in to the
    panel in a

    browser to do them:


    - Create, edit or revoke API keys

    - Edit the IP groups that restrict API keys

    - End signed-in sessions

    - Change two-factor authentication

    - Change the account's email address

    - Accept or decline team invitations

    - Switch or leave a team


    This keeps a leaked key from widening its own access or locking you out of
    your account.


    ## Source IP restrictions


    A key can be restricted to one or more IP groups. Requests from other
    addresses are rejected.


    ## Requests and responses


    Each endpoint lists its path, query, header, and body parameters. Examples
    use fictional data.


    Single records use JSON objects. Collections use JSON arrays unless the
    endpoint supports pagination. Timestamps use ISO 8601 in UTC.


    Error responses include `message`. Validation errors also include an
    `errors` object for each field. Each endpoint lists its status codes.


    ## Audit log


    Every API request, including reads, is recorded in the account audit log
    with the key that made it.
servers:
  - url: https://console.advinservers.com/api/v1/client
security:
  - http: []
tags:
  - name: Account
    description: Billing contact details and account setup progress.
  - name: Account activity
    description: Actions performed in the current team by people and API keys.
  - name: Servers
    description: >-
      Order and list servers, read their state and resource use, open a console,
      and control power.
  - name: Server settings
    description: >-
      Rename a server, rebuild it, and change its hardware, media, resolvers and
      credentials.
  - name: Backups
    description: Scheduled server copies stored separately from the server.
  - name: Snapshots
    description: >-
      Take, restore and move server snapshots. Snapshots are kept in snapshot
      storage that the team buys by the GiB.
  - name: Firewall groups
    description: Reusable sets of firewall rules, and the servers they apply to.
  - name: IP groups
    description: Reusable source address lists for firewall rules.
  - name: Server firewall
    description: >-
      Read default traffic policies and rules managed outside your firewall
      groups.
  - name: IP addresses
    description: Manage floating IPs and server address assignments.
  - name: Private networks
    description: Connect servers over a private network in the same location.
  - name: Reverse DNS
    description: Set the hostnames returned by IP address lookups.
  - name: DDoS protection
    description: Configure attack filtering for server addresses.
  - name: Bandwidth
    description: Buy extra bandwidth and share it between servers or location pools.
  - name: SSH keys
    description: Public keys the account can install on a server when it is built.
  - name: Setup scripts
    description: Scripts the account can run on a server when it is built.
  - name: ISO images
    description: ISO images you have downloaded, and the servers they are mounted on.
  - name: Server upgrades
    description: Change an existing server's plan.
  - name: Checkout
    description: Choose a payment method and pay for a purchase.
  - name: Invoices
    description: View and pay account invoices.
  - name: Billing
    description: Manage service renewals, payment methods and account credit.
  - name: Transfers
    description: Move resources between teams or transfer ownership.
  - name: Teams
    description: Manage the team assigned to your API key.
  - name: Team members
    description: Invite people and manage their team access.
  - name: Team roles
    description: Define the permissions granted to team members.
  - name: Team activity
    description: View actions performed in a team.
  - name: Support tickets
    description: >-
      Open, read, reply to and close support tickets. Tickets belong to the
      account holder and are not shared with team members.
paths:
  /user-scripts/{userScript}:
    patch:
      tags:
        - Setup scripts
      summary: Update a setup script
      description: >-
        ### Overview


        Updates a setup script. Send `name`, `type` and the full `content`, even
        if only one changes. Servers previously configured with the script are
        not changed.


        ### Permissions


        Requires the `script.update` (Manage setup scripts) permission for the
        selected team. Resources outside that team return 404.
      operationId: userScript.update
      parameters:
        - name: userScript
          in: path
          required: true
          description: The user script UUID
          schema:
            type: string
            examples:
              - 8edb21bc-9aee-4bd9-8a02-17043fa82a87
          example: 8edb21bc-9aee-4bd9-8a02-17043fa82a87
      requestBody:
        description: >-
          Send a JSON object containing the fields below. Required fields are
          marked in the schema.
        required: true
        content:
          application/json:
            schema:
              type: object
              examples:
                - name: HEV telemetry agent
                  type: cloud-config
                  content: |
                    #cloud-config
                    package_update: true
                    packages:
                      - nginx
                      - prometheus-node-exporter
                    write_files:
                      - path: /etc/hev/telemetry.env
                        content: |
                          SECTOR=C
                          LAB=anomalous-materials
                    runcmd:
                      - systemctl enable --now nginx prometheus-node-exporter
              properties:
                name:
                  type: string
                  description: >-
                    A name unique across the account, 1 to 64 characters,
                    without control characters.
                  examples:
                    - HEV telemetry agent
                type:
                  type: string
                  description: >-
                    Use cloud-config for configuration settings or bash for a
                    shell script.
                  enum:
                    - cloud-config
                    - bash
                  examples:
                    - cloud-config
                content:
                  type: string
                  description: The complete script, up to 1 MiB.
                  examples:
                    - |
                      #cloud-config
                      package_update: true
                      packages:
                        - nginx
                        - prometheus-node-exporter
                      write_files:
                        - path: /etc/hev/telemetry.env
                          content: |
                            SECTOR=C
                            LAB=anomalous-materials
                      runcmd:
                        - systemctl enable --now nginx prometheus-node-exporter
              required:
                - name
                - type
                - content
      responses:
        '200':
          description: The record, as a JSON object. There is no envelope.
          content:
            application/json:
              schema:
                examples:
                  - id: 8edb21bc-9aee-4bd9-8a02-17043fa82a87
                    name: HEV telemetry agent
                    type: cloud-config
                    content: |
                      #cloud-config
                      package_update: true
                      packages:
                        - nginx
                        - prometheus-node-exporter
                      write_files:
                        - path: /etc/hev/telemetry.env
                          content: |
                            SECTOR=C
                            LAB=anomalous-materials
                      runcmd:
                        - systemctl enable --now nginx prometheus-node-exporter
                    owner:
                      name: Gordon Freeman
                      email: gordon.freeman@blackmesa.example.com
                    created_at: '2026-03-02T18:58:40+00:00'
                    updated_at: '2026-06-19T10:12:05+00:00'
                allOf:
                  - $ref: '#/components/schemas/UserScriptData'
        '401':
          description: >-
            The key was missing, malformed, revoked, or belongs to an account
            that no longer exists.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    examples:
                      - Unauthenticated.
                required:
                  - message
        '403':
          description: >-
            Access denied. Check the key's team, permissions and allowed IP
            addresses. Some actions, such as managing API keys, require a
            browser session. The response message explains the reason.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    examples:
                      - >-
                        This API key is not allowed to do that in this team. It
                        needs the "snapshot.delete" permission.
                required:
                  - message
        '404':
          description: >-
            The resource was not found in the selected team. Resources in
            another account or team also return 404.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    examples:
                      - Not found.
                required:
                  - message
        '422':
          description: >-
            A field is missing or invalid, or the resource cannot accept this
            change in its current state. Check `message` for details. Field
            validation also includes an `errors` object keyed by field name.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A summary of the validation error or the reason the change
                      was refused.
                    examples:
                      - The name field is required.
                  errors:
                    type: object
                    description: Validation errors grouped by field name.
                    additionalProperties:
                      type: array
                      items:
                        type: string
                required:
                  - message
        '429':
          description: >-
            Too many requests. The `Retry-After` header says how many seconds to
            wait. Limits are per account, so several keys on one account share
            them.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    examples:
                      - Too Many Attempts.
                required:
                  - message
components:
  schemas:
    UserScriptData:
      type: object
      description: A script that runs while a server is provisioned.
      examples:
        - id: 8edb21bc-9aee-4bd9-8a02-17043fa82a87
          name: HEV telemetry agent
          type: cloud-config
          content: |
            #cloud-config
            package_update: true
            packages:
              - nginx
              - prometheus-node-exporter
            write_files:
              - path: /etc/hev/telemetry.env
                content: |
                  SECTOR=C
                  LAB=anomalous-materials
            runcmd:
              - systemctl enable --now nginx prometheus-node-exporter
          owner:
            name: Gordon Freeman
            email: gordon.freeman@blackmesa.example.com
          created_at: '2026-03-02T18:58:40+00:00'
          updated_at: '2026-06-19T10:12:05+00:00'
      properties:
        id:
          type: string
          description: The uuid. A script's autoincrement id never leaves the server.
          examples:
            - 8edb21bc-9aee-4bd9-8a02-17043fa82a87
        name:
          type: string
          description: The name shown to customers.
          examples:
            - HEV telemetry agent
        type:
          type: string
          description: The type of operation or resource.
          enum:
            - cloud-config
            - bash
          examples:
            - cloud-config
        content:
          type: string
          description: >-
            The complete script content, which may contain credentials. Stored
            encrypted and readable by its owner.
          examples:
            - |
              #cloud-config
              package_update: true
              packages:
                - nginx
                - prometheus-node-exporter
              write_files:
                - path: /etc/hev/telemetry.env
                  content: |
                    SECTOR=C
                    LAB=anomalous-materials
              runcmd:
                - systemctl enable --now nginx prometheus-node-exporter
        owner:
          description: The value of `owner`.
          examples:
            - name: Gordon Freeman
              email: gordon.freeman@blackmesa.example.com
          anyOf:
            - $ref: '#/components/schemas/AccountOwnerData'
            - type: 'null'
        created_at:
          type:
            - string
            - 'null'
          description: The date and time for created at, in UTC.
          examples:
            - '2026-03-02T18:58:40+00:00'
        updated_at:
          type:
            - string
            - 'null'
          description: The date and time for updated at, in UTC.
          examples:
            - '2026-06-19T10:12:05+00:00'
      required:
        - id
        - name
        - type
        - content
        - owner
        - created_at
        - updated_at
      title: UserScriptData
    AccountOwnerData:
      type: object
      description: Whose key or script this is, in the two words a listing has room for.
      examples:
        - name: Gordon Freeman
          email: gordon.freeman@blackmesa.example.com
      properties:
        name:
          type: string
          description: The name shown to customers.
          examples:
            - Gordon Freeman
        email:
          type: string
          description: The email address.
          examples:
            - gordon.freeman@blackmesa.example.com
      required:
        - name
        - email
      title: AccountOwnerData
  securitySchemes:
    http:
      type: http
      description: >-
        Your API key, sent as a bearer token. Create one in the control panel
        under API Keys, give it only the permissions the integration needs, and
        copy it when it is created. It cannot be shown again. Each key is
        restricted to one owned team. The key determines the team for every
        request.
      scheme: bearer

````

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