Allocate IP Address Using API

Hi All
New to fly so bear with me. I’m following Machines · Fly Docs

I am using the API (not cli) to create apps and machines but I can’t seem to make an app available over the internet. I realise it’s to do with allocating an IP address which seems easy enough with the cli but I don’t see the equivalent for the API.

When creating an app I send this payload:

{
  app_name: "app-name",
  org_slug: "org-name",
  no_public_ips: false, // thought this might help but NO!
  vm_size: "shared-cpu-1x",
  internal_port: 3000,
  ha: true
}

I have machine with services configured but still no luck???

Any idea most welcome

We currently support allocating IPs via our old GraphQL API only. Here’s an example in Elixir:

  def allocate_ip(app_name, type) do
    query = """
    mutation ($input: AllocateIPAddressInput!) {
      allocateIpAddress(input: $input) {
        ipAddress {
          address
        }
      }
    }
    """

    Req.post(graphql_config(),
      json: %{query: query, variables: %{input: %{appId: app_name, type: type}}}
    )
  end

  defp graphql_config do
    Req.new(base_url: "https://api.fly.io/graphql", auth: {:bearer, api_token()})
  end

Apologies for the confusion

Thanks for that. Got it working now.

Are there plans to add this functionality into the standard API at some point?

That’s our endgame but I don’t think it’s on any teams roadmap at the moment

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.