The desktop and phone apps are coming soon.

Join the waitlist
On this page

CI keys and importing routes

A build knows its own routes. With a CI key, it can send them to Diver after every build, so your team's templates never drift from the code.

In one minute

  1. An owner or admin creates a key in the admin console, for the organisation or one app. It is shown once.
  2. Store it in CI as DIVER_API_KEY.
  3. After the build, post the app's routes to the import endpoint. The import replaces the previous one.

Create a key#

In the admin console at admin.usediver.com, an organisation's settings have API keys: give the key a name, pick All apps or one app, and Create key. The console shows the key once: Set this as DIVER_API_KEY in CI - it's shown once and can't be recovered. Only the owner and admins can create or revoke keys.

What a key can do is small on purpose. It reads the organisation (or its one app) and imports routes; it cannot write templates by hand, see who has access or see the plan. Diver keeps only a hash of the key and the time it was last used. A key stops working when it is revoked, when its app is deleted, or when the person who created it loses admin on the organisation or their seat; keys the owner created are not revoked that way.

Import the routes#

Post the routes to the app's import endpoint with the key as a bearer token. An example, with made-up ids:

shell
curl -X POST "https://api.usediver.com/organizations/$ORG_ID/apps/$APP_ID/import" \
  -H "Authorization: Bearer $DIVER_API_KEY" \
  -H "Content-Type: application/json" \
  --data @routes.json
json
{
  "org_id": "7d1f0c3a-example",
  "app_id": "2b9e4c11-example",
  "routes": [
    {
      "host": "products",
      "path": "/:productId",
      "name": "Product detail",
      "description": "One product, by id",
      "query": [
        { "name": "sort", "type": "string" },
        { "name": "preview", "type": "boolean" },
        { "name": "size", "type": "enum", "values": ["small", "large"] }
      ]
    }
  ]
}

The body carries org_id and app_id as well as the path; the endpoint uses the app in the path. Each route has a host and, optionally, a path, a name, a description and its query parameters, each with a name, a type (string, boolean, list or enum), whether it is required, and for enum its values in order. A route has no fragment.

What an import changes#

An import replaces the app's previous import. Diver first removes every template the last import created, then adds each route as a template marked imported; templates written by hand are left alone. The same host and path keep the same id from one import to the next. The answer is the list of templates.

In the app an imported template carries the imported chip and has no edit or delete: A build imported this route, so it cannot be edited or deleted here. The next import would undo the change.

Who can import#

A CI key, the owner, admins and members can all import. A signed-in person's own token works in place of a key, which is handy to try an import before putting it in CI.