Projects and Applications

In this section you will create a Platform project and application to help scope and model the data for this scenario. The project contains all the resources relevant to this API walkthrough, whereas the application represents a mobile app that interacts with the data detailing the state of the supply chain and lets you create Application Users, who are responsible for creating the data.


Creating a Project

A project is the top level of scoping in an EVRYTHNG account. By scoping individual resources to different projects, you can control who has access to them, separate concerns, and easily view only resources that are relevant to the project. To create your first project, make a POST /projects request and include the required fields in the payload:

📘

Note

If you haven't exported OPERATOR_API_KEY, remember to replace this manually in the examples that follow.

curl -H "Content-Type: application/json" \
  -H "Authorization: $OPERATOR_API_KEY" \
  -X POST 'https://api.evrythng.com/projects' \
  -d '{
    "name": "Supply Chain Project",
    "description": "A project for all the supply chain resources.",
    "tags": ["Tagged Products"]
  }'
HTTP/1.1 201 Created
Content-Type: application/json

{
  "id": "UGhQAe3eeXswQ5wwagWUNKaq",
  "createdAt": 1501508756298,
  "tags": [
    "Tagged Products"
  ],
  "updatedAt": 1501508756298,
  "name": "Supply Chain Project",
  "description": "A project for all the supply chain resources.",
  "shortDomains": [
    "tn.gg"
  ]
}

The response contains an id field, which is the project’s unique identifier. Make a note of this now for use in the rest of this walkthrough. To read it again in the future, make a GET /projects request at any time using your Operator API Key in the same manner.

With this newly created project, we can correctly scope future resources created in this walkthrough to keep them tidily all in one place. Scooping is usually done by including the project query parameter, as you will see in the upcoming examples.


Creating an Application

Every project on the Platform, such as the one you just created, can contain one or more application resources. Whereas a project resource helps scope resources, applications help manage access to resources. For example, you can give access to individual Application Users who, on each login, are given their own Application User API Key with access to only those resources in the project they're scoped to.

The application resource is most commonly used to model the interactions with the Platform resources through a client mobile/web application. It contains a special Application API Key to let the third-party app make requests with the right level of access. You obtain one of these below.

Create an application through the API by making a POST /projects/:projectId/applications request. You'll need the ID of the project the application will belong to. Use the noted ID from the POST /projects response, or make a GET /projects request to find it again.

Substitutions: :projectId

curl -H "Content-Type: application/json" \
  -H "Authorization: $OPERATOR_API_KEY" \
  -X POST 'https://api.evrythng.com/projects/:projectId/applications' \
  -d '{
    "name": "Warehouse Manager Mobile App",
    "description": "A mobile app to manage warehouse stock.",
    "socialNetworks": {}
  }'
HTTP/1.1 201 Created
Content-Type: application/json

{
  "id": "UGE9dWaxBXsRtKRwaDdWnepa",
  "createdAt": 1501508865613,
  "updatedAt": 1501508865613,
  "name": "Warehouse Manager Mobile App",
  "description": "A mobile app to manage warehouse stock.",
  "project": "UGhQAe3eeXswQ5wwagWUNKaq",
  "socialNetworks": {},
  "appApiKey": "xnDkdhezgJ2Mnx6fGAxzPJpgM31xc0sb4fsQ2edG...",
  "defaultRole": "base_app_user"
}

Note the appApiKey value. This is the application’s Application API Key, which mobile or web applications use to interact with the Platform resources. The Application API Key also lets you create and manage Application Users. These users create and manage their own resources representing products and Thngs. We cover this in the next sections.