{
  "info": {
    "name": "CoreHost API",
    "description": "The CoreHost API. Set the token variable to an API token from https://corehost.io/profile#api-tokens and app_id to one of your app ids. Docs: https://corehost.io/developers/api",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "auth": {
    "type": "bearer",
    "bearer": [
      {
        "key": "token",
        "value": "{{token}}",
        "type": "string"
      }
    ]
  },
  "variable": [
    {
      "key": "base_url",
      "value": "https://api.corehost.io/v1"
    },
    {
      "key": "token",
      "value": ""
    },
    {
      "key": "app_id",
      "value": ""
    },
    {
      "key": "backup_id",
      "value": ""
    },
    {
      "key": "invoice_number",
      "value": ""
    }
  ],
  "item": [
    {
      "name": "Public",
      "item": [
        {
          "name": "List the apps you can deploy",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/catalog",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "catalog"
              ],
              "query": []
            },
            "description": "List the apps you can deploy",
            "auth": {
              "type": "noauth"
            }
          }
        },
        {
          "name": "List regions",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/regions",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "regions"
              ],
              "query": []
            },
            "description": "List regions",
            "auth": {
              "type": "noauth"
            }
          }
        }
      ]
    },
    {
      "name": "Account",
      "item": [
        {
          "name": "Describe the calling token",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/me",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "me"
              ],
              "query": []
            },
            "description": "Any valid token may call this; no scope is needed."
          }
        }
      ]
    },
    {
      "name": "Apps",
      "item": [
        {
          "name": "List your apps",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/apps",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "apps"
              ],
              "query": []
            },
            "description": "Newest first. Deleted apps are not listed. Requires `read`."
          }
        },
        {
          "name": "Get one app",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/apps/{{app_id}}",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "apps",
                "{{app_id}}"
              ],
              "query": []
            },
            "description": "Includes live resource usage when the app is running. Requires `read`."
          }
        },
        {
          "name": "Delete an app",
          "request": {
            "method": "DELETE",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "{{$guid}}",
                "disabled": true
              }
            ],
            "url": {
              "raw": "{{base_url}}/apps/{{app_id}}?confirm={{app_id}}",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "apps",
                "{{app_id}}"
              ],
              "query": [
                {
                  "key": "confirm",
                  "value": "{{app_id}}"
                }
              ]
            },
            "description": "Requires `apps:delete`. **Deletes the app and its data now.** Billing\nfor the app stops; the rest of your balance stays on the account. To\ngo ahead you must repeat the app id in the query string as\n`?confirm={app_id}`. Take a backup and download it first if you want\nto keep the data."
          }
        },
        {
          "name": "Rebuild an app",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "{{$guid}}",
                "disabled": true
              }
            ],
            "url": {
              "raw": "{{base_url}}/apps/{{app_id}}/rebuild",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "apps",
                "{{app_id}}",
                "rebuild"
              ],
              "query": []
            },
            "description": "Requires `apps:write`. Reinstalls the app's container and pulls its\nimage again. Data on the app's volume is kept. The app restarts; poll\n`GET /apps/{app_id}` for `power_state`. Refused with `409 app_busy`\nwhile an automatic update is running."
          }
        },
        {
          "name": "Start, stop, restart or kill an app",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Idempotency-Key",
                "value": "{{$guid}}",
                "disabled": true
              }
            ],
            "url": {
              "raw": "{{base_url}}/apps/{{app_id}}/power",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "apps",
                "{{app_id}}",
                "power"
              ],
              "query": []
            },
            "description": "Requires `apps:write`. The action is sent to the app at once; poll\n`GET /apps/{app_id}` for `power_state`. A stopped app bills at the\nstorage-only rate until it is started again. `kill` stops the app\nwithout a clean shutdown; prefer `stop`.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"action\": \"restart\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          }
        },
        {
          "name": "Read recent console output",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/apps/{{app_id}}/logs",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "apps",
                "{{app_id}}",
                "logs"
              ],
              "query": []
            },
            "description": "A short snapshot of the app's recent console output (the same stream\nthe dashboard console shows), with colour codes removed. At most\n6000 characters, newest at the end. Requires `read`."
          }
        }
      ]
    },
    {
      "name": "Settings",
      "item": [
        {
          "name": "Read app settings",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/apps/{{app_id}}/settings",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "apps",
                "{{app_id}}",
                "settings"
              ],
              "query": []
            },
            "description": "Requires `read`."
          }
        },
        {
          "name": "Change app settings",
          "request": {
            "method": "PATCH",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Idempotency-Key",
                "value": "{{$guid}}",
                "disabled": true
              }
            ],
            "url": {
              "raw": "{{base_url}}/apps/{{app_id}}/settings",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "apps",
                "{{app_id}}",
                "settings"
              ],
              "query": []
            },
            "description": "Requires `apps:write`. Send only the fields you want to change.\n`auto_update` can only be turned on for apps that support automatic\nupdates (otherwise `400`). Environment variables and the firewall are\nnot available through the API yet.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"notify_on_updates\": true,\n  \"update_window_start_utc\": 3\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          }
        }
      ]
    },
    {
      "name": "Backups",
      "item": [
        {
          "name": "List an app's backups",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/apps/{{app_id}}/backups",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "apps",
                "{{app_id}}",
                "backups"
              ],
              "query": []
            },
            "description": "Newest first. Requires `read`."
          }
        },
        {
          "name": "Start a backup",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "{{$guid}}",
                "disabled": true
              }
            ],
            "url": {
              "raw": "{{base_url}}/apps/{{app_id}}/backups",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "apps",
                "{{app_id}}",
                "backups"
              ],
              "query": []
            },
            "description": "Requires `apps:write`. The backup runs in the background; it is\ncomplete when its `status` is `completed`. Each app has a limited\nnumber of backup slots; when they are full you get `409`\n`backup_limit_reached` and should delete an old backup first."
          }
        },
        {
          "name": "Delete a backup",
          "request": {
            "method": "DELETE",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "{{$guid}}",
                "disabled": true
              }
            ],
            "url": {
              "raw": "{{base_url}}/apps/{{app_id}}/backups/{{backup_id}}",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "apps",
                "{{app_id}}",
                "backups",
                "{{backup_id}}"
              ],
              "query": []
            },
            "description": "Requires `apps:delete`. Locked backups cannot be deleted (`409`)."
          }
        },
        {
          "name": "Get a backup download link",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/apps/{{app_id}}/backups/{{backup_id}}/download",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "apps",
                "{{app_id}}",
                "backups",
                "{{backup_id}}",
                "download"
              ],
              "query": []
            },
            "description": "Requires `apps:write`, because a backup holds all of the app's data,\nincluding anything secret inside it. Returns a short-lived link. Fetch\nit soon after you get it and do not share it. Only finished backups\ncan be downloaded."
          }
        },
        {
          "name": "Restore a backup",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Idempotency-Key",
                "value": "{{$guid}}",
                "disabled": true
              }
            ],
            "url": {
              "raw": "{{base_url}}/apps/{{app_id}}/backups/{{backup_id}}/restore",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "apps",
                "{{app_id}}",
                "backups",
                "{{backup_id}}",
                "restore"
              ],
              "query": []
            },
            "description": "Requires `apps:write`. **Replaces the app's current data with the\nbackup.** You must send `{\"confirm\": true}`. Incomplete or near-empty\nbackups are refused (`400 backup_incomplete`) so a bad archive can't\nwipe your app. The restore runs in the background.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"confirm\": true\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          }
        }
      ]
    },
    {
      "name": "Billing",
      "item": [
        {
          "name": "Balance and burn rate",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/billing",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "billing"
              ],
              "query": []
            },
            "description": "Requires `billing:read`."
          }
        },
        {
          "name": "Balance ledger",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/billing/ledger",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "billing",
                "ledger"
              ],
              "query": []
            },
            "description": "Every change to your balance, newest first: top-ups, hourly usage\ndraws, credits and refunds. Requires `billing:read`."
          }
        },
        {
          "name": "List invoices",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/invoices",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "invoices"
              ],
              "query": []
            },
            "description": "One invoice per paid top-up, newest first. Invoice numbers look like\n`CHIO-` followed by random characters. Requires `billing:read`."
          }
        },
        {
          "name": "Get an invoice PDF link",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/invoices/{{invoice_number}}",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "invoices",
                "{{invoice_number}}"
              ],
              "query": []
            },
            "description": "Returns a short-lived link to the invoice PDF. Requires `billing:read`."
          }
        }
      ]
    }
  ]
}
