Apps
You can use the Apps resource to create and manage Fly Apps. A Fly App is an abstraction for a group of Machines running your code, along with the configuration, provisioned resources, and data we need to keep track of to run and route to your Machines. Learn more about Fly Apps.
Create a Fly App
POST /apps
Machines must be associated with a Fly App. App names must be unique.
- Responses
-
-
201
: -
created
-
curl -i -X POST \\
-H "Authorization: Bearer ${FLY_API_TOKEN}" -H "Content-Type: application/json" \\
"${FLY_API_HOSTNAME}/v1/apps" \\
-d '{
"app_name": "my-app-name",
"org_slug": "personal",
"network": "my-optional-network"
}'
{
"id":"z4k69dxd8r31p5mx",
"created_at":1708631799000
}
To segment the app into its own network, you can pass a network
argument in the JSON body, for example: "network": "some-arbitrary-name"
. Any Machine started in such an app will not be able to access other apps within their organization over the private network. However, Machines within such an app can communicate to each other, and the fly-replay
header can still be used to route requests to Machines within a segmented app.
Allocate an IP address for global request routing
If you intend for Machines to be accessible to the internet, you’ll need to allocate an IP address to the app. Currently
this is done using flyctl
or the Fly.io GraphQL API. This offers your app automatic, global routing via Anycast. Read more about this in the Networking section.
Example:
fly ips allocate-v4 -a my-app-name
TYPE ADDRESS REGION CREATED AT
v4 37.16.9.52 global 7s ago
The app will answer on this IP address, and after a small delay, at my-app-name.fly.dev
.
Get app details
GET /apps/{app_name}
Get details about an app, like its organization slug and name. Also, to check if the app exists!
- Path parameters
-
-
app_name
: string required -
The name of the Fly App to get the details of.
-
- Responses
-
-
200
: -
OK
-
curl -i -X GET \\
-H "Authorization: Bearer ${FLY_API_TOKEN}" -H "Content-Type: application/json" \\
"${FLY_API_HOSTNAME}/v1/apps/my-app-name"
{
"id": "jlyv9r5d56v18xrg",
"name": "my-app-name",
"status": "pending",
"organization": {
"name": "My Org",
"slug": "personal"
}
}
Set app secrets
For sensitive environment variables, such as credentials, you can set secrets on the app:
fly secrets set DATABASE_URL=postgres://example.com/mydb <my-app-name>
Machines inherit secrets from the app. Existing Machines must be updated to pick up secrets set after the Machine was created.
For non-sensitive information, you can configure environment variables per Machine when you create or update the Machine.
Delete a Fly App
DELETE /apps/{app_name}
Machines should be stopped before attempting deletion. Append ?force=true
to the URI to stop and delete immediately.
- Path parameters
-
-
app_name
: string required -
The name of the Fly App to delete.
-
- Query parameters
-
-
force
: Boolean -
Stop all Machines and delete the app immediately.
-
- Responses
-
-
202
: -
accepted
-
curl -i -X DELETE \\
-H "Authorization: Bearer ${FLY_API_TOKEN}" -H "Content-Type: application/json" \\
"${FLY_API_HOSTNAME}/v1/apps/my-app-name"
no body
List apps in an organization
GET /apps?org_slug=
- Query parameters
-
-
org_slug
: string required -
The organization to list apps for.
-
- Responses
-
-
200
: -
OK
-
curl -i -X GET \\
-H "Authorization: Bearer ${FLY_API_TOKEN}" -H "Content-Type: application/json" \\
"${FLY_API_HOSTNAME}/v1/apps?org_slug=personal"
{
"total_apps": 4,
"apps": [
{
"id": "682kqp6pdno9d543",
"name": "my-app-1",
"machine_count": 3,
"network": "default"
},
...
]
}
Related topics
- Working with the Machines API
- Machines resource reference
- Tokens resource reference
- Volumes resource reference