Apps API

Creating an App

POST /v2/apps/

Request

Route

POST /v2/apps

Body

Name Description Default Valid Values Example Values
name The name of the app.
  • my_super_app
memory The amount of memory each instance should have. In megabytes.
  • 1024
  • 512
instances The number of instances of the app to run. To ensure optimal availability, ensure there are at least 2 instances.
  • 2
  • 6
  • 10
disk_quota The maximum amount of disk available to an instance of an app. In megabytes.
  • 1204
  • 2048
space_guid The guid of the associated space.
  • guid-bffb125b-1563-4ed1-9b5a-4dd16e565533
stack_guid The guid of the associated stack. Uses the default system stack.
  • guid-44b22d6d-3f46-4b84-bc7e-f7179d2de304
state The current desired state of the app. One of STOPPED or STARTED. STOPPED
  • STOPPED
  • STARTED
command The command to start an app after it is staged, maximum length: 4096 (e.g. 'rails s -p $PORT' or 'java com.org.Server $PORT').
buildpack Buildpack to build the app. 3 options: a) Blank means autodetection; b) A Git Url pointing to a buildpack; c) Name of an installed buildpack.
  • https://github.com/virtualstaticvoid/heroku-buildpack-r.git
  • an_example_installed_buildpack
health_check_http_endpoint Endpoint called to determine if the app is healthy.
  • /health
health_check_type Type of health check to perform. 'none' is deprecated and an alias to 'process'. port
  • http (Diego only)
  • port
  • process
  • none
health_check_timeout Timeout in seconds for health checking of an staged app when starting up
diego Use diego to stage and to run when available false
  • true
  • false
enable_ssh Enable SSHing into the app. Supported for Diego only. false if SSH is disabled globally or on the space, true if enabled for both
  • true
  • false
docker_image Name of the Docker image containing the app. The "diego_docker" feature flag must be enabled in order to create Docker image apps.
  • cloudfoundry/diego-docker-app
  • registry.example.com:5000/user/repository/tag
docker_credentials Docker credentials for pulling docker image. {}
  • {"username": "user", "password": "password"}
environment_json Key/value pairs of all the environment variables to run in your app. Does not include any system or service variables.
production Deprecated. true
  • true
  • false
console Open the console port for the app (at $CONSOLE_PORT). false
  • true
  • false
debug Open the debug port for the app (at $DEBUG_PORT). false
  • true
  • false
staging_failed_reason Reason for application staging failures
  • StagingError
  • StagingTimeExpired
staging_failed_description Detailed description for the staging_failed_reason
  • An app was not successfully detected by any available buildpack
ports Ports on which application may listen. Overwrites previously configured ports. Ports must be in range 1024-65535. Supported for Diego only.
  • [5222, 8080]
  • [1056]
{
  "name": "my_super_app",
  "space_guid": "55821877-4e20-4af4-b0e5-9d376964b027",
  "diego": true,
  "ports": [
    1024,
    2000
  ]
}

Headers

Authorization: bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidWFhLWlkLTQ0MCIsImVtYWlsIjoiZW1haWwtMzAyQHNvbWVkb21haW4uY29tIiwic2NvcGUiOlsiY2xvdWRfY29udHJvbGxlci5hZG1pbiJdLCJhdWQiOlsiY2xvdWRfY29udHJvbGxlciJdLCJleHAiOjE0NjYwMDg5MDR9.aRYwZhBBnF6vS38odmTfyoDW61UczQ8DcYGHZ-S-hYI
Host: example.org
Content-Type: application/json
Cookie: 

cURL

curl "https://api.[your-domain.com]/v2/apps" -d '{
  "name": "my_super_app",
  "space_guid": "55821877-4e20-4af4-b0e5-9d376964b027",
  "diego": true,
  "ports": [
    1024,
    2000
  ]
}' -X POST \
	-H "Authorization: bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidWFhLWlkLTQ0MCIsImVtYWlsIjoiZW1haWwtMzAyQHNvbWVkb21haW4uY29tIiwic2NvcGUiOlsiY2xvdWRfY29udHJvbGxlci5hZG1pbiJdLCJhdWQiOlsiY2xvdWRfY29udHJvbGxlciJdLCJleHAiOjE0NjYwMDg5MDR9.aRYwZhBBnF6vS38odmTfyoDW61UczQ8DcYGHZ-S-hYI" \
	-H "Host: example.org" \
	-H "Content-Type: application/json" \
	-H "Cookie: "

Response

Status

201 Created

Body

{
  "metadata": {
    "guid": "1573f4ca-4df3-41cb-9111-23e2a5d7ad65",
    "url": "/v2/apps/1573f4ca-4df3-41cb-9111-23e2a5d7ad65",
    "created_at": "2016-06-08T16:41:44Z",
    "updated_at": "2016-06-08T16:41:26Z"
  },
  "entity": {
    "name": "my_super_app",
    "production": false,
    "space_guid": "55821877-4e20-4af4-b0e5-9d376964b027",
    "stack_guid": "5603073e-38d3-4309-8bd1-460efa4a8c15",
    "buildpack": null,
    "detected_buildpack": null,
    "detected_buildpack_guid": null,
    "environment_json": {

    },
    "memory": 1024,
    "instances": 1,
    "disk_quota": 1024,
    "state": "STOPPED",
    "version": "31d1703a-8050-4357-a8f1-551d4136110a",
    "command": null,
    "console": false,
    "debug": null,
    "staging_task_id": null,
    "package_state": "PENDING",
    "health_check_http_endpoint": "",
    "health_check_type": "port",
    "health_check_timeout": null,
    "staging_failed_reason": null,
    "staging_failed_description": null,
    "diego": true,
    "docker_image": null,
    "docker_credentials": {
      "username": null,
      "password": null
    },
    "package_updated_at": null,
    "detected_start_command": "",
    "enable_ssh": true,
    "ports": [
      1024,
      2000
    ],
    "space_url": "/v2/spaces/55821877-4e20-4af4-b0e5-9d376964b027",
    "stack_url": "/v2/stacks/5603073e-38d3-4309-8bd1-460efa4a8c15",
    "routes_url": "/v2/apps/1573f4ca-4df3-41cb-9111-23e2a5d7ad65/routes",
    "events_url": "/v2/apps/1573f4ca-4df3-41cb-9111-23e2a5d7ad65/events",
    "service_bindings_url": "/v2/apps/1573f4ca-4df3-41cb-9111-23e2a5d7ad65/service_bindings",
    "route_mappings_url": "/v2/apps/1573f4ca-4df3-41cb-9111-23e2a5d7ad65/route_mappings"
  }
}

Headers

Content-Type: application/json;charset=utf-8
Location: /v2/apps/1573f4ca-4df3-41cb-9111-23e2a5d7ad65
X-VCAP-Request-ID: 7ec11aab-26f8-4285-bdf7-e9080f56ac3f
Content-Length: 1622
X-Content-Type-Options: nosniff

Audit Records Created By The Request

Audit Record: audit.app.create

Attribute Name Value
id 32
guid ef4b523c-8ac5-4d1b-bbf9-7262922c1666
created_at 2016-06-08 16:41:44 UTC
updated_at
timestamp 2016-06-08 16:41:44 UTC
type audit.app.create
actor uaa-id-440
actor_type user
actee 1573f4ca-4df3-41cb-9111-23e2a5d7ad65
actee_type app
metadata
{
  "request": {
    "name": "my_super_app",
    "space_guid": "55821877-4e20-4af4-b0e5-9d376964b027",
    "diego": true,
    "ports": [
      1024,
      2000
    ],
    "console": false,
    "environment_json": "PRIVATE DATA HIDDEN",
    "health_check_type": "port",
    "instances": 1,
    "production": false,
    "state": "STOPPED"
  }
}
space_id
organization_guid 6351722a-320b-42b2-a686-199b74e64325
space_guid 55821877-4e20-4af4-b0e5-9d376964b027
actor_name [email protected]
actee_name my_super_app