Skip to main content

Get the project ID and environment ID

Get the project ID or key and the environment ID or key that most Permit API endpoints require in their path, such as /v2/facts/{project_id}/{env_id}/users. This page is for developers who call the Permit API from scripts or backend code. Every endpoint accepts either the ID or the key.

To copy the IDs from the dashboard instead, see Get the project ID and Get the environment ID.

Prerequisites

  • An environment API key (Get your API key). Copy the API key of an environment in the project you want the IDs for.

In each request on this page, replace API_SECRET_KEY with your environment API key.

Get the project ID or key

Send a GET request to the List Projects API.

Request the project object

curl 'https://api.permit.io/v2/projects' \
-H 'authorization: Bearer API_SECRET_KEY'

The API responds with an array of project objects:

[
{
"key": "project_key",
"urn_namespace": null,
"id": "3c4244c7bcab4c97990e5bc724dxxxx",
"organization_id": "903ebc2765b848289d6dfbd3c21xxxx",
"created_at": "2023-02-28T10:07:44+00:00",
"updated_at": "2023-06-22T08:46:42+00:00",
"name": "Project Name",
"description": "",
"settings": {
"abacEnabled": true
},
"active_policy_repo_id": null
}
]

Copy the id or the key of your project from the project object.

Get the environment ID or key

Send a GET request to the List Environments API. Use the same environment API key, and replace project_id_or_key in the path with the project ID or key from Get the project ID or key.

Request the environment object

curl 'https://api.permit.io/v2/projects/project_id_or_key/envs' \
-H 'authorization: Bearer API_SECRET_KEY'

The API responds with an array of environment objects:

[
{
"key": "env_key",
"id": "20cce46340594f98b03c2189e40cxxxx",
"organization_id": "903ebc2765b848289d6dfbd3c21exxxx",
"project_id": "3c4244c7bcab4c97990e5bc724daxxxx",
"created_at": "2023-05-16T12:47:10+00:00",
"updated_at": "2023-05-16T12:47:10+00:00",
"name": "Env Name",
"description": null,
"custom_branch_name": null,
"jwks": null,
"settings": null,
"email_configuration": null
}
]

Copy the id or the key of your environment from the environment object.

Verify the IDs

Use the project and environment IDs or keys in a request that needs them, such as the list users request in Filter users. A successful response with a data array confirms that the IDs match an environment your API key can access.

Next steps