Skip to main content
TypeScript and Python examples require SDK 6.3.1 or later. Go examples require v6.4.0 or later.
Use an API key (dr_sk_…) in your backend for server access to the Mobilerun API. Give a browser or app a stream token (dr_st_…) when it needs to show and control one device, without exposing your API key.

API keys

The allows you to generate and manage authentication keys for accessing the Mobilerun API. Use API keys to integrate Mobilerun into your applications, CI/CD pipelines, and automation workflows.

Overview

API keys provide:
  • Authentication for API requests
  • Programmatic access limited by the key’s permissions and your role
  • Integration with external tools and services

Creating an API Key

Issue keys in the dashboard’s API Keys tab:
  1. Click New key to open the New API key dialog
  2. Enter a descriptive key label (e.g., “Production CI runner”)
  3. Choose an expiration: Never, 24 hours, 1 week, 1 month, 3 months, 6 months, or 1 year. Restricted keys also offer Default (90 days)
  4. Under Access, select Restricted to choose permissions, then start from a preset or select individual actions. Select at least one permission. Choose Full access only when the integration needs everything your role allows
  5. Click Issue key
  6. Copy the generated key immediately
API keys are only displayed once at creation. Store your key securely as you will not be able to view it again.
Mobilerun API keys always start with the prefix dr_sk_. Pass the full key, including the prefix, as a bearer token in the form Authorization: Bearer dr_sk_.... This is a different credential from your LLM provider keys such as GOOGLE_API_KEY or OPENAI_API_KEY, which are only used by the local Framework. See the two kinds of API keys for guidance on when to use each one.

Permissions

Presets

Presets are starting points for restricted keys. You can change the selected actions before issuing the key. Only permissions your role can grant are included; full access permissions are excluded from presets.

Custom permissions

Choose actions for each resource in the Permissions panel. The picker groups resources under Devices & apps, App store, Agents & automation, Files, Credentials, Numbers, mail & network, Developer, Serverless Functions, Sandbox, Wallet, and Organization, when permissions are available for that group. Actions depend on the resource: for example, Devices offer Read, Control, and Stream; Apps offer Read and Create; Tasks and Routines offer Read and Control; Credentials have their own actions for accessing and managing stored credentials. Select only the actions your integration needs. Actions your role cannot grant are disabled, and sensitive actions are marked Sensitive. Permissions apply across your organization, including all its devices; they do not restrict a key to one device. The End customer field is a display label, not an access restriction. Keep these keys in your backend rather than handing them to end customers.

Full access

Full access means everything your role allows. Issuing a key requires permission to create API keys; choosing Full access does not give you or the key permissions beyond your role.
Some permissions inside the restricted picker also confer full authority. The Routines (full access) section warns that a routine runs with your full access, not with the key’s selected permissions. Enabling Allow creating and changing routines lets the key do anything you can through routines. Other such permissions appear under Full access permissions. You can grant them only when your role allows them.

When a request is outside the key’s permissions

A request denied because the key lacks the required scope returns HTTP 403 with code api_key_scope_denied. For example, an endpoint that refuses scoped keys returns:
Check the key’s granted permissions against the operation you are calling. Issue a replacement key with the required permission, update your integration, and revoke the old key. The dashboard currently does not offer editing an existing key’s permissions. Your role must also allow the operation; granting a key more permissions cannot expand your own access.

Managing API Keys

Your API key list displays: The Access details also warn about Full access via routines or other Full access permissions, when applicable. The row menu’s Edit end customer action changes only the display label, not permissions. To change access, issue a replacement key.

Revoke Keys

Delete API keys that are no longer needed or may have been compromised. Revoked keys immediately stop working for all API requests.
Revoking a key cannot be undone. You will need to create a new key and update any integrations that used the old key.

Using API Keys

Include your API key in the request headers when calling the Mobilerun API:
If you are new to the API, the Cloud Quickstart walks through the full flow in TypeScript, Python, Go, and cURL. It covers finding a device, running a task, and reading the result.

Authentication Header

All API requests require the Authorization header:

API Documentation

The complete API reference is available via OpenAPI specification. Access the full documentation to explore all available endpoints:
  • Tasks - Create, monitor, and manage agent tasks
  • Devices - List and manage your devices
  • Apps - Upload and install applications
  • Credentials - Manage stored credentials
  • Hooks - Configure webhooks for task events

API Reference

View the complete API documentation with request/response schemas and examples.

Best Practices

Environment Variables

Store your API key as an environment variable rather than hardcoding it:
For mobilerun CLI commands that use Cloud devices, sign in with mobilerun login or set MOBILERUN_API_KEY.
Then reference it in your code or scripts:

Check which key you are using

identity.me() returns the user, the owner and the authentication method of the credential that made the request. It does not change anything, so it is a quick way to confirm that MOBILERUN_API_KEY holds the key you expect. apiKeyId is set when the request used an API key.

Stream tokens

A stream token lets a browser or app view and control one device for a single stream connection. It also allows publishing microphone and camera input when the device supports call media and media injection is enabled for your organization. It cannot mint credentials or call other API routes. Your backend must authenticate the user and authorize access to the requested device before minting a token; never send the API key to the frontend. viewOnly is not supported: including it in a mint request, even as false, returns HTTP 422. A client-side control setting does not reduce the token’s authority.

Create a token in the dashboard

  1. Select New key.
  2. Switch to Stream token, pick the device and a validity, and select Create token.
  3. Select Test in viewer to check the stream, or use the token in your app.
The token is shown once. Keep it out of logs, analytics, traces, error reports, and local storage.

Required permissions

Your backend’s API key needs these permissions in Devices & apps:
  • Stream keys: Create (stream_key.create)
  • Devices: Stream (device.stream)
  • Devices: Control (device.control)
Add Stream keys: Delete (stream_key.delete) if the key should revoke tokens. The picker calls the resource Stream keys, while the issued dr_st_… credential is a stream token. The key and its creator’s role must allow the operation.

Mint via the API

POST /v1/identity/stream-keys accepts a device UUID, optional ttlSeconds, and optional allowedOrigins. It returns HTTP 201 with key (the stream token), keyId (for revocation), and expiresAt. Use @mobilerun/sdk or mobilerun-sdk 6.3.1 or later, or the Go SDK v6.4.0 or later. The SDK reads MOBILERUN_API_KEY from the environment. Run this only in your backend, after checking the user may access the device:

Revoke via the API

DELETE /v1/identity/stream-keys/{keyId} revokes an owned stream token and returns HTTP 204. Use keyId from the mint response; repeating a revoke for that owned token is safe.

Lifetime and limits

  • ttlSeconds is an integer from 60 to 86400 seconds (24 hours), default 120 seconds. A deployment may enforce a lower maximum.
  • A token is bound to one device and is consumed by its first admitted stream connection. Each reconnect needs a fresh token; an unused token expires at expiresAt.
  • allowedOrigins optionally binds the token to 1–10 exact origins: HTTPS origins or http://localhost[:port]. Paths, wildcards, queries, and fragments are not accepted. Without this field, no browser-origin restriction is applied.
  • Origin binding limits browser embedding. A non-browser client can set its own Origin header, so this does not replace your application’s authorization checks.
  • The default organization limit is 500 live unused tokens.
  • Revoking or disabling the API key that minted a token invalidates its unused tokens.
Stream tokens minted before the prefix change may still begin with dr_sk_ until they expire, for up to 24 hours. Treat any dr_sk_ value as a backend secret; do not use the prefix alone to decide whether a credential can be exposed.

Stream-token errors

See Embed a device stream for the authenticated backend route, React component, and reconnect flow.