Connecting to the API
API addresses
There are two base URLs available to connect to the Machines API service. Internal base URL:http://_api.internal:4280
Public base URL: https://api.machines.dev
From within your Fly.io private WireGuard network, you can connect to the API directly using the internal endpoint. From outside the Fly.io WireGuard mesh, use the public endpoint; this proxies your request to the API.
Authentication
All requests must include an API token in the HTTP headers as follows:<fly_api_token> with a Fly.io authentication token.
Environment setup
The examples in the Machines API reference docs assume that you have two environment variables set:FLY_API_TOKEN, the authorization token to use with the API call; and FLY_API_HOSTNAME, the API base URL.
For local development, you might set them as follows, assuming you have flyctl installed and have authenticated to Fly.io:
fly tokens deploy command creates a token capable of managing the application in your current directory. See fly tokens create --help for information on other types of tokens you can generate.
To set an access token as an environment variable on Fly Machines, use a secret; for example: