Projects and Applications
In this section, you create a Platform project and application to help scope and model the data and access for this scenario. The project contains all the resources relevant to this API walkthrough. The application represents a web app that provides the product scanning experience and lets you create Application Users who perform the actual product scans.
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 as shown below:
Note
If you're using cURL and have not exported
OPERATOR_API_KEY
, remember to replace$OPERATOR_API_KEY
with the API key manually in the examples.
curl -H "Content-Type: application/json" \
-H "Authorization: $OPERATOR_API_KEY" \
-X POST 'https://api.evrythng.io/v2/projects' \
-d '{
"name": "Consumer Engagement Project",
"description": "A project for all the Consumer Engagement resources.",
"tags": ["Consumer Engagement"]
}'
HTTP/1.1 201 Created
Content-Type: application/json
{
"id": "UGhQAe3eeXswQ5wwagWUNKaq",
"createdAt": 1501508756298,
"tags": [
"Consumer Engagement"
],
"updatedAt": 1501508756298,
"name": "Consumer Engagement Project",
"description": "A project for all the Consumer Engagement 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 in one place. This is usually done by including the project
query parameter, as shown in the examples.
Creating an Application
Every project in the Platform can contain one or more application resources. A project resource helps scope resources, and applications help manage access to resources. For example, access can be given 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 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 get one of these by following the process below.
Create an application through the API by making a POST /projects/:projectId/applications
request. This requires the ID of the project you want the application to belong to. Use the ID from the POST /projects
response, or make a GET /projects
request to get it again.
Substitutions: :projectId
curl -H "Content-Type: application/json" \
-H "Authorization: $OPERATOR_API_KEY" \
-X POST 'https://api.evrythng.io/v2/projects/:projectId/applications' \
-d '{
"name": "Scanning Web App",
"description": "A web app to scan products.",
"socialNetworks": {}
}'
HTTP/1.1 201 Created
Content-Type: application/json
{
"id": "UGE9dWaxBXsRtKRwaDdWnepa",
"createdAt": 1501508865613,
"updatedAt": 1501508865613,
"name": "Scanning Web App",
"description": "A web app to scan products.",
"project": "UGhQAe3eeXswQ5wwagWUNKaq",
"socialNetworks": {},
"appApiKey": "ejj05OmVhXbfPHzgg...",
"defaultRole": "base_app_user"
}
Make a note of the appApiKey
value. The application’s Application API Key allows mobile or web applications to interact with the Platform resources, as well as to create and manage Application Users. These users create and manage their own resources, such as actions representing product scans. For more information, see the next sections.
Updated about 2 years ago