API¶
You can automate your Asteroid's configuration through the Marvin API, which is also used by the uberspace command.
The API base URL is https://marvin.uberspace.is/api/v1/.
The customer-facing API has three endpoint groups with different purposes:
| Endpoint | Purpose |
|---|---|
/api/v1/external/asteroids/<username>/ |
Read and change your Asteroid's configuration. Supported methods depend on the resource. |
/api/v1/external/tools/ |
Read the catalog of available tools and versions. Select a version for your Asteroid through its configuration endpoints. |
/api/v1/common/events/ |
Read the progress and logs of background changes. Use the event IDs returned by configuration requests. |
The API reference describes request fields, response bodies, and allowed methods. It also contains internal endpoints; use the three endpoint groups described here for your Asteroid.
Authentication¶
Each Asteroid has an API key in /readonly/<username>/marvin_client.toml, in the api_key field.
Authenticate requests with the header Authorization: Api-Key <your-key>.
Use the Asteroid's name in URLs, and its own key for authentication.
The key does not grant administrative access to other Asteroids or hosts.
Treat this key like a password: anyone with it can change your Asteroid's configuration. Keep it out of source control and logs. If you use the API from another computer, store the key securely there and send requests over HTTPS.
What you can manage¶
The paths below are relative to /api/v1/external/asteroids/<username>/.
Replace placeholders with your own Asteroid, domain, or resource identifiers.
| Area | Path | Available operations |
|---|---|---|
| Asteroid settings | The Asteroid URL itself | Read details; change log settings, the replacement HTTP 500 page, and the SSH password. |
| Web domains | webdomains/ |
List, add, inspect, and remove domains; read DNS validation status. |
| Web backends | webdomains/<domain>/backends/ |
List, add, inspect, and remove backends for a domain. |
| HTTP response headers | webdomains/<domain>/headers/ |
List, add, inspect, and remove headers for a domain. |
| Mail domains | maildomains/ |
List, add, inspect, and remove mail domains. |
| Mail users | maildomains/<domain>/users/ |
List, add, inspect, update, and remove mail users. |
| Mail forwarding | maildomains/<domain>/users/<local>/forwards/ |
List, add, inspect, and remove forwarding destinations. |
| SSH keys | sshkeys/ |
List, add, inspect, and remove keys. |
| PostgreSQL databases | postgresdatabases/ |
List, create, inspect, and remove databases. |
| Software versions | toolversions/ |
List selected versions; read or change a tool's selection at toolversions/<tool>/. |
You can also list all mail users, web backends, and web headers for your Asteroid at mailusers/, webbackends/, and webheaders/.
For these Asteroid configuration endpoints, use GET to read, POST to create, PATCH to update supported fields, and DELETE to remove a resource.
Check the reference for each endpoint's methods and required fields; not every resource supports every method.
Keep the trailing slash in URLs, and URL-encode domain names, paths, or addresses when needed.
Normal requirements still apply, such as configuring and verifying DNS for web domains.
Available tools and versions¶
The /api/v1/external/tools/ endpoints provide a read-only catalog of available software, separate from your Asteroid's configuration.
Use GET /api/v1/external/tools/ to list tools and GET /api/v1/external/tools/<tool>/versions/ to list a tool's available versions.
To read or change the version selected for your Asteroid, use /api/v1/external/asteroids/<username>/toolversions/<tool>/ instead.
Requests and responses¶
Send request bodies as JSON with Content-Type: application/json, and request JSON responses with Accept: application/json.
The API reference lists the writable fields for each endpoint. Fields marked read-only describe the resource and cannot be changed through that request.
List responses are paginated: entries are in results, and next contains the next page's URL or null when there are no more pages.
Follow next to retrieve the entire collection. List endpoints also accept limit and offset query parameters.
A successful deletion generally returns HTTP 204 with no response body.
Deleting a mailbox or database can also delete its stored data.
Wait for changes to finish¶
Configuration changes can be processed in the background. An HTTP success response does not by itself mean the change has finished on the host.
When a response includes X-MARVIN-EVENT-ID, use its event IDs to check progress.
The header can contain multiple comma-separated IDs; check each one.
Use GET with your Asteroid's key to read events at /api/v1/common/events/<id>/ and their logs at /api/v1/common/events/<id>/logs/.
These shared endpoints report background processing; configuration changes go through the Asteroid configuration endpoints.
Read the event's state to check the result:
DONE: processing completed.FAILED: processing failed; inspect the event's logs.SKIPPED: the event was skipped; inspect its logs and check the resulting resource.
For other states, wait briefly before checking again. Once processing finishes, read the affected external endpoint again to confirm its configuration.
Errors¶
Read the HTTP response body for details: 400 usually indicates invalid input, 403 indicates an authentication or permission problem, and 404 indicates an unavailable resource or incorrect URL.
If a change times out, check the resource and any event IDs you received before repeating it: the server may already have accepted the request.