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

# Queue an asynchronous RouterOS script

> Queues a RouterOS script for execution on a managed site. Use asynchronous scripts for configuration changes, backups, and work that should be tracked as a device job.



## OpenAPI

````yaml /api/en/mikrotik-api.yaml post /api/asynchronous/{siteId}
openapi: 3.0.3
info:
  title: Altostrat MikroTik Devices API
  version: 1.0.0
  description: >-
    The Altostrat MikroTik Devices API is the microservice responsible for
    managing the lifecycle, configuration, and real-time state of MikroTik
    devices within the SDX platform.


    It acts as the command and control plane for individual network endpoints,
    receiving heartbeats, dispatching jobs, and providing observability into
    device health. This service is the bridge between the Altostrat SDX
    automation layer and the physical network hardware.


    This API allows you to programmatically manage:

    - **Sites:** The digital twin of a physical MikroTik router, representing
    its identity, configuration, and current online status.

    - **Jobs:** Asynchronous commands or scripts sent to a Site for execution,
    enabling remote configuration changes, troubleshooting, and automation.

    - **Device Stats:** Time-series performance data, including CPU load, memory
    usage, and uptime, collected from each Site.


    Developers use this API to programmatically list, monitor, and interact with
    their fleet of MikroTik devices, forming the basis for building custom
    network automation and management tools.
servers:
  - url: https://v1.api.altostrat.io
    description: Production API Server
security:
  - BearerAuth: []
tags:
  - name: Sites
    description: Manage and monitor MikroTik devices, referred to as "Sites".
  - name: Jobs
    description: Create and manage asynchronous commands to be executed on Sites.
  - name: Device Stats
    description: Retrieve time-series performance metrics from Sites.
  - name: Runbooks
    description: Access device onboarding configurations.
  - name: Developer API
    description: >-
      Run synchronous RouterOS commands or queue asynchronous RouterOS scripts
      through SDX.
  - name: Developer Routers
    description: Read router-level summaries exposed by the SDX developer API.
paths:
  /api/asynchronous/{siteId}:
    post:
      tags:
        - Developer API
      summary: Queue an asynchronous RouterOS script
      description: >-
        Queues a RouterOS script for execution on a managed site. Use
        asynchronous scripts for configuration changes, backups, and work that
        should be tracked as a device job.
      operationId: queueAsynchronousRouterScript
      parameters:
        - name: siteId
          in: path
          required: true
          description: The target site/router UUID.
          schema:
            type: string
            format: uuid
            example: 9c69345c-8d39-4786-9f17-8153c988c89a
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AsynchronousScriptRequest'
            example:
              description: Add guest network address
              script: /ip address add address=192.168.99.1/24 interface=bridge
              make_backup: true
              express_execute: true
              needs_acknowledgement: true
              notify_url: https://example.com/sdx/job-complete
      responses:
        '202':
          description: The script was accepted for asynchronous execution.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AsynchronousScriptResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  schemas:
    AsynchronousScriptRequest:
      type: object
      required:
        - description
        - script
      properties:
        description:
          type: string
          example: Add guest network address
        script:
          type: string
          example: /ip address add address=192.168.99.1/24 interface=bridge
        make_backup:
          type: boolean
          default: false
          description: Create a configuration backup before running the script.
        express_execute:
          type: boolean
          default: false
          description: Ask SDX to trigger a faster device check-in where possible.
        needs_acknowledgement:
          type: boolean
          default: false
          description: Require the device job to acknowledge completion.
        notify_url:
          type: string
          format: uri
          nullable: true
          description: Optional HTTPS callback URL for job status notification.
          example: https://example.com/sdx/job-complete
    AsynchronousScriptResponse:
      type: object
      properties:
        status:
          type: string
          example: success
        data:
          type: object
          properties:
            idempotency_key:
              type: string
              example: f9e2b0a1-7f12-4d35-9c86-7ebfe33ac18b
            request_id:
              type: string
              example: 5f9475ef-565f-5d10-8a86-4c7f5fdb2687
            target:
              type: string
              format: uuid
              example: 9c69345c-8d39-4786-9f17-8153c988c89a
            notify_url:
              type: string
              format: uri
              nullable: true
              example: https://example.com/sdx/job-complete
            date:
              type: string
              format: date-time
              example: '2026-04-20T03:14:15+00:00'
    ErrorResponse:
      type: object
      properties:
        type:
          type: string
          description: A broad category for the error (e.g., 'invalid_request_error').
          example: invalid_request_error
        code:
          type: string
          description: A short, unique string identifying the specific error.
          example: parameter_invalid
        message:
          type: string
          description: A human-readable description of what went wrong.
          example: The 'lat' parameter must be between -90 and 90.
        doc_url:
          type: string
          description: >-
            A direct link to the documentation page for this specific error
            code.
          example: https://docs.altostrat.io/errors/parameter_invalid
  responses:
    BadRequest:
      description: >-
        Bad Request - The request was malformed or invalid. Check the response
        body for details.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: Unauthorized.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    NotFound:
      description: Not found.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Authenticate requests by providing a JSON Web Token (JWT) in the
        `Authorization` header. Example: `Authorization: Bearer <YOUR_JWT>`

````