Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion blueprints/warm-pool-user-machines.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ curl -X POST "https://api.machines.dev/v1/apps" \
-H "Authorization: Bearer ${FLY_API_TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"app_name": "pool-x7f3k2",
"name": "pool-x7f3k2",
"org_slug": "my-org",
"network": "pool-x7f3k2"
}'
Expand Down
40 changes: 36 additions & 4 deletions machines/api/apps-resource.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ You can use the Apps resource to create and manage Fly Apps. A Fly App is an abs
<span className="w-16 shrink-0 text-center rounded-full bg-emerald-800/60 text-emerald-300 text-xs font-mono py-1">POST</span>
<span className="text-slate-200 font-mono text-sm">/v1/apps</span>
</a>
<a href="#allocate-an-ip-address-for-global-request-routing" className="flex items-center gap-3 no-underline hover:opacity-80">
<span className="w-16 shrink-0 text-center rounded-full bg-emerald-800/60 text-emerald-300 text-xs font-mono py-1">POST</span>
<span className="text-slate-200 font-mono text-sm">/v1/apps/{'{app_name}'}/ip_assignments</span>
</a>
<a href="#get-app-details" className="flex items-center gap-3 no-underline hover:opacity-80">
<span className="w-16 shrink-0 text-center rounded-full bg-sky-900/60 text-sky-300 text-xs font-mono py-1">GET</span>
<span className="text-slate-200 font-mono text-sm">/v1/apps/{'{app_name}'}</span>
Expand All @@ -38,7 +42,7 @@ Machines must be associated with a Fly App. App names must be unique.

#### Body parameters

<ParamField body="app_name" type="string" required>
<ParamField body="name" type="string" required>
Name of the app to create
</ParamField>

Expand All @@ -59,7 +63,7 @@ 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",
"name": "my-app-name",
"org_slug": "personal",
"network": "my-optional-network"
}'
Expand All @@ -76,9 +80,37 @@ To segment the app into its own network, you can pass a `network` argument in th

## 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](https://api.fly.io/graphql). This offers your app automatic, global routing via [Anycast](/networking/services#about-anycast). Read more about this in [the Networking section](/machines/api/machines-resource#notes-on-networking).
`POST /v1/apps/{app_name}/ip_assignments`

If you intend for Machines to be accessible to the internet, you’ll need to allocate an IP address to the app, with this endpoint or with `flyctl`. This offers your app automatic, global routing via [Anycast](/networking/services#about-anycast). Read more about this in [the Networking section](/machines/api/machines-resource#notes-on-networking).

#### Body parameters

<ParamField body="type" type="string" required>
Type of IP address to allocate: `shared_v4` (an IPv4 address shared with other apps), `v4` (a dedicated IPv4 address), `v6`, or `private_v6` (a [Flycast](/networking/flycast) address). The [OpenAPI spec](https://docs.machines.dev/openapi.json) also lists the egress types.
</ParamField>

```sh title="POST/v1/apps/{app_name}/ip_assignments"
curl -i -X POST \
-H "Authorization: Bearer ${FLY_API_TOKEN}" -H "Content-Type: application/json" \
"${FLY_API_HOSTNAME}/v1/apps/my-app-name/ip_assignments" \
-d '{"type": "shared_v4"}'
```

```json title="Status: 200 OK - Example response"
{
"ip": "66.241.125.240",
"region": null,
"service_name": null,
"shared": true,
"created_at": null,
"egress": false,
"network": null,
"ip_pair": null
}
```

Example:
With flyctl:

<CodeGroup>
```sh cmd
Expand Down
2 changes: 1 addition & 1 deletion machines/api/machines-resource.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ Filter for a specific Machine `instance_id` (version). Required when waiting for
</ParamField>

<ParamField query="timeout" type="integer">
The time, in seconds, to wait for the Machine to enter the specified state. Default is 60.
The time, in seconds, to wait for the Machine to enter the specified state: a whole number from 1 to 60. Default is 60.
</ParamField>

<ParamField query="state" type="string enum">
Expand Down
38 changes: 6 additions & 32 deletions model-context-protocol/deploy-with/machines-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

To get started, you need an organization token, which you can obtain via the dashboard.

Go to https://fly.io/dashboard, change the organization if necessary, select Tokens from the list on the left hand side of the page, optionally enter a token name or an expiration period and click on Create Organization token. Once complete you should see something like the following:

Check warning on line 28 in model-context-protocol/deploy-with/machines-api.mdx

View workflow job for this annotation

GitHub Actions / Vale linter

[vale] reported by reviewdog 🐶 Consider using 'click' or 'click in' instead of 'click on'. Raw Output: {"message":"Consider using 'click' or 'click in' instead of 'click on'.","location":{"path":"model-context-protocol/deploy-with/machines-api.mdx","range":{"start":{"line":28,"column":192},"end":{"line":28,"column":200}}},"severity":"INFO","code":{"value":"Fly.WordList"}}

![Obtaining an organization token via the dashboard](/images/orgtoken.png)

Expand Down Expand Up @@ -61,7 +61,7 @@
-H "Content-Type: application/json" \
"${FLY_API_HOSTNAME}/v1/apps" \
-d "{ \
\"app_name\": \"${APP_NAME}\", \
\"name\": \"${APP_NAME}\", \
\"org_slug\": \"${ORG}\" \
}"
```
Expand All @@ -70,46 +70,20 @@

## Create IP addresses for your application

<Note>
While the Fly.io GraphQL endpoint is public, our [usage of it](https://github.com/superfly/fly-go/blob/main/resource_ip_addresses.go) is [open source](https://github.com/superfly/fly-go/blob/main/LICENSE), can be directly observed by setting `LOG_LEVEL=debug` before running `flyctl` commands, and there are no current plans to change it, be aware that this interface is not guaranteed to be stable and can change without notice. If this is a concern, consider using the [`fly ips`](/flyctl/cmd/fly_ips) command instead.
</Note>

The following will create a shared IPv4 address and a dedicated IPv6 address:
The following uses the [Allocate an IP address](/machines/api/apps-resource#allocate-an-ip-address-for-global-request-routing) API to create a shared IPv4 address and a dedicated IPv6 address:

```json
curl -i -X POST \
-H "Authorization: Bearer ${FLY_API_TOKEN}" \
-H "Content-Type: application/json" \
"https://api.fly.io/graphql" \
-d @- <<EOF
{
"query": "mutation(\$input: AllocateIPAddressInput!) { allocateIpAddress(input: \$input) { app { sharedIpAddress } } }",
"variables": {
"input": {
"appId": "${APP_NAME}",
"type": "shared_v4",
"region": ""
}
}
}
EOF
"${FLY_API_HOSTNAME}/v1/apps/${APP_NAME}/ip_assignments" \
-d '{"type": "shared_v4"}'

curl -i -X POST \
-H "Authorization: Bearer ${FLY_API_TOKEN}" \
-H "Content-Type: application/json" \
"https://api.fly.io/graphql" \
-d @- <<EOF
{
"query": "mutation(\$input: AllocateIPAddressInput!) { allocateIpAddress(input: \$input) { ipAddress { id address type region createdAt } } }",
"variables": {
"input": {
"appId": "${APP_NAME}",
"type": "v6",
"region": ""
}
}
}
EOF
"${FLY_API_HOSTNAME}/v1/apps/${APP_NAME}/ip_assignments" \
-d '{"type": "v6"}'
```

Other options include `v4` and `private_v6`.
Expand Down
2 changes: 1 addition & 1 deletion networking/custom-private-networks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ 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",
"name": "my-app-name",
"org_slug": "personal",
"network": "my-custom-network-name"
}'
Expand Down
2 changes: 1 addition & 1 deletion snippets/reference/machines/create-app-req.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ 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",
"name": "my-app-name",
"org_slug": "personal"
}'

Expand Down
2 changes: 1 addition & 1 deletion snippets/reference/machines/create-app.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ 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",
"name": "my-app-name",
"org_slug": "personal",
"network": "my-app-name-network"
}'
Expand Down
Loading