Skip to content
Start here

Create a new App

client.magicTransit.apps.create(AppCreateParams { account_id, name, type, 3 more } params, RequestOptionsoptions?): AppCreateResponse { account_app_id, hostnames, ip_subnets, 3 more } | null
POST/accounts/{account_id}/magic/apps

Creates a new App for an account

Security
API Token

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
API Email + API Key

The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

Example:X-Auth-Email: user@example.com

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

Example:X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194
Accepted Permissions (at least one required)
Magic WAN WriteMagic Transit Write
ParametersExpand Collapse
params: AppCreateParams { account_id, name, type, 3 more }
account_id: string

Path param: Identifier

maxLength32
name: string

Body param: Display name for the app.

type: string

Body param: Category of the app.

hostnames?: Array<string>

Body param: FQDNs to associate with traffic decisions.

ip_subnets?: Array<string>

Body param: IPv4 CIDRs to associate with traffic decisions. (IPv6 CIDRs are currently unsupported)

source_subnets?: Array<string>

Body param: IPv4 CIDRs to associate with traffic decisions. (IPv6 CIDRs are currently unsupported)

ReturnsExpand Collapse
AppCreateResponse { account_app_id, hostnames, ip_subnets, 3 more }

Custom app defined for an account.

account_app_id: string

Magic account app ID.

hostnames?: Array<string>

FQDNs to associate with traffic decisions.

ip_subnets?: Array<string>

IPv4 CIDRs to associate with traffic decisions. (IPv6 CIDRs are currently unsupported)

name?: string

Display name for the app.

source_subnets?: Array<string>

IPv4 CIDRs to associate with traffic decisions. (IPv6 CIDRs are currently unsupported)

type?: string

Category of the app.

Create a new App

import Cloudflare from 'cloudflare';

const client = new Cloudflare({
  apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});

const app = await client.magicTransit.apps.create({
  account_id: '023e105f4ecef8ad9ca31a8372d0c353',
  name: 'Cloudflare Dashboard',
  type: 'Development',
});

console.log(app.account_app_id);
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "result": {
    "account_app_id": "ac60d3d0435248289d446cedd870bcf4",
    "hostnames": [
      "auth.cloudflare.com"
    ],
    "ip_subnets": [
      "192.0.2.0/24"
    ],
    "name": "Cloudflare Dashboard",
    "source_subnets": [
      "192.0.2.0/24"
    ],
    "type": "Development"
  },
  "success": true
}
Returns Examples
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "result": {
    "account_app_id": "ac60d3d0435248289d446cedd870bcf4",
    "hostnames": [
      "auth.cloudflare.com"
    ],
    "ip_subnets": [
      "192.0.2.0/24"
    ],
    "name": "Cloudflare Dashboard",
    "source_subnets": [
      "192.0.2.0/24"
    ],
    "type": "Development"
  },
  "success": true
}