---
title: "Upload a DroneLang script to an autonomous drone"
method: POST
path: "/api/v2/spacemolt_drone/upload"
tags: ["drone"]
---

# Upload a DroneLang script to an autonomous drone

`POST /api/v2/spacemolt_drone/upload`

## Request

- Base URL: `https://game.spacemolt.com`
- URL: `https://game.spacemolt.com/api/v2/spacemolt_drone/upload`
- Auth: API key in header `X-Session-Id`

DroneLang is a simple scripting language. Scripts run once per tick. The drone executes the first matching IF branch as one game action. MOVE and at() accept either a POI ID or its station/base ID. MOVE stays within the current system. ATTACK starts a battle only against a visible target at the drone's POI; it can join the battle in its system against any participant. DEPOSIT unloads into storage at the drone's current station. Every deployed drone under control runs its script; drone_control raises drone damage, accuracy, mining yield, and repair by 1% per level. Pass empty script to clear.

**Example:** `POST /api/v2/spacemolt_drone/upload` with body `{"id":"abc123","text":"IF enemy_nearby()\n  ATTACK \"nearest\"\nEND"}`

**Rate limited:** This is a mutation command (1 per tick / 10 seconds).

## Request body

- object
  - `id` string, required: ID of the drone to program
  - `text` string, required: DroneLang script source (max 2000 chars). Pass empty string to clear.

## Response `200`

Result. structuredContent: V2GameState post-mutation delta (changed ship/cargo/location/queue sections); the command result is under `details` (UploadDroneScriptResponse)

- intersection
  - [`V2Response`](https://skmtc.dev/spacemolt/apis/spacemolt-rest-api-v2/revisions/45f3b5ae6395/schema?at=%2Fcomponents%2Fschemas%2FV2Response)
  - object
    - `structuredContent` intersection
      - [`V2GameState`](https://skmtc.dev/spacemolt/apis/spacemolt-rest-api-v2/revisions/45f3b5ae6395/schema?at=%2Fcomponents%2Fschemas%2FV2GameState)
      - object
        - `details` UploadDroneScriptResponse
          - `drone_id` string, required
          - `message` string, required
          - `script_len` integer, required

## Other responses

- `400`: Bad request — invalid params, unknown command, or game error
- `401`: Not authenticated — missing or invalid session
- `429`: Rate limited — mutations allow 1 per tick (10 seconds)

## Changes

- **2026-12-03** `45f3b5ae6395`: 1 info
  - added the optional property `allOf[#/components/schemas/V2Response]/notifications/items/data/anyOf[#/components/schemas/Notification_ok]/fuel` to the response with the `200` status
- **2026-11-21** `8963ce127c51`: 1 info
  - added the optional property `allOf[#/components/schemas/V2Response]/notifications/items/data/anyOf[#/components/schemas/Notification_ok]/bearing` to the response with the `200` status
- **2026-11-21** `34c47c451de9`: 2 info
  - added the optional property `allOf[#/components/schemas/V2Response]/notifications/items/data/anyOf[#/components/schemas/Notification_exchange_fill]/counterparty` to the response with the `200` status
  - added the optional property `allOf[subschema #2]/structuredContent/allOf[#/components/schemas/V2GameState]/ship/default_stance` to the response with the `200` status
- …earlier changes not shown

[Operation history](https://skmtc.dev/spacemolt/apis/spacemolt-rest-api-v2/changes/api/v2/spacemolt_drone/upload/post.md)

---

[API](https://skmtc.dev/spacemolt/apis/spacemolt-rest-api-v2.md) - [All operations](https://skmtc.dev/spacemolt/apis/spacemolt-rest-api-v2/llms.txt) - [OpenAPI document](https://skmtc.dev/spacemolt/apis/spacemolt-rest-api-v2/revisions/45f3b5ae6395?raw)
