Projects and Applications

In this section we will create a Platform project and application to help scope and model the data for this scenario. The project will contain all the resources relevant to this API walkthrough, whereas the application will represent a mobile app that will interact with the data detailing the state of the supply chain, and allow creation of Application Users who will be responsible for creating the data.


## Creating a Project

A project is the top-most 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 have not exported OPERATOR_API_KEY, remember to replace this manually in the subsequent examples.

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 will contain 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. This is usually done by including the project query parameter, as you will see in the upcoming examples.


## Creating an Application

Every project in 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, access can be given to individual Application Users, who on each login are each given their own Application User API Key with access to only those resources in the project they are scoped to.

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

Creating an application through the API is done by making a POST /projects/:projectId/applications request, which requires 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"
}

Make a note of the appApiKey value - this is the application’s Application API Key, and is used to allow mobile or web applications to interact with the Platform resources, as well as to create and manage Application Users. These users will be the ones creating and managing their own resources representing products and things. We will cover all this in the next sections.