As an Ory Network user you can configure and administer your projects using the console, as well as the powerful Ory CLI. You can fully control your Ory Network project using the CLI and in 99% of use cases the command line or console is the best choice to manage your Ory Network projects.
Install the Ory CLI now if you haven't already!

But there are edge cases where you might want to use the API directly. There is a way to look "under the hood" and use the projects API. If you're new to using the Ory projects endpoint, you might find the process has a learning curve. While we're working to improve the experience, we've put together a guide that will help you get started.

To run this guide you need:

  • curl
  • your Ory Network Project ID
  • an active Ory Console session

A quick way to get a valid administrative session is to copy your session from Ory Console using Chrome DevTools:

  1. Open the Chrome browser and navigate to the Ory Console.
  2. Press F12 to open the Chrome DevTools.
  3. Click on the "Application" tab in the DevTools window.
  4. Expand the "Cookies" dropdown in the sidebar and select https://console.ory.sh/.
  5. Find the ory_session_ory cookie and click on it. The cookie details will appear in the right-hand pane. Click on the "Value" field to select and copy the entire value.

Screenshot showing the console cookie in dev-tools

Export it using the terminal, or any similar method.

export ORY_SESSION=<your-ory-cookie-here>

Now export your Ory Network Project ID and you are all set to use the snippets below.

export ORY_ID=<your-ory-project-id-here>

Ory Network projects API snippets

listProjects

List all your Ory Network projects, including stats like creation time, last update time and more using the listProjects API.

curl -X GET https://api.console.ory.sh/projects \
    -H "Accept: application/json" \
    --cookie "ory_session_ory=$ORY_SESSION"| jq

createProject

Create a new Ory Network project through the API. You get the full configuration of the newly created project as response using the createProject API.

curl -X POST https://api.console.ory.sh/projects \
    -d '{"name":"example"}' \
    -H "Content-Type: application/json" \
    --cookie "ory_session_ory=$ORY_SESSION"| jq

getProject

To get the full configuration of your Ory Network project use the getProject API.

curl -X GET https://api.console.ory.sh/projects/$ORY_ID \
    -H "Accept: application/json" \
    --cookie "ory_session_ory=$ORY_SESSION"| jq

purgeProject

To delete and irrevocably purge an Ory Network project use the purgeProject API.

curl -X DELETE https://api.console.ory.sh/projects/$ORY_ID  \
    -H "Accept: application/json" \
    --cookie "ory_session_ory=$ORY_SESSION"
warning

This is a permanent deletion and it is not possible to recover your project once it is deleted/purged this way!

getProjectMembers

To get all members of an Ory Network project, their ID, names and email use the getProjectMembers.

curl -X GET https://api.console.ory.sh/projects/$ORY_ID/members \
    -H "Accept: application/json" \
    --cookie "ory_session_ory=$ORY_SESSION"| jq

removeProjectMember

With the member ID from the API above, we can remove members also using the removeProjectMember API.

export MEMBERID=<the-members-ID>
curl -X DELETE https://api.console.ory.sh/projects/$ORY_ID/members\$MEMBERID \
    -H "Accept: application/json" \
    --cookie "ory_session_ory=$ORY_SESSION"

listProjectApiKeys

List all API Keys active using the listProjectApiKeys API, including creation dates, name and ID. Please note that you can not get the value this way, it is only shown once upon creation of the API Key.

curl -X GET https://api.console.ory.sh/projects/$ORY_ID/tokens \
    -H "Accept: application/json" \
    --cookie "ory_session_ory=$ORY_SESSION"| jq

createProjectApiKey

Use the createProjectApiKey API to create a new API Key. The output is similar to above, with the difference that you can see the value now (this is the only time you see it!).

curl -X POST https://api.console.ory.sh/projects/$ORY_ID/tokens \
    -d '{"name":"example"}' \
    -H "Content-Type: application/json" \
    --cookie "ory_session_ory=$ORY_SESSION"| jq

deleteProjectApiKey

In the same way you can also delete an API Key that is no longer used. You need the API Key ID to delete it with the deleteProjectApiKey API.

export APIKEY_ID=<your-api-key-id>
curl -X DELETE https://api.console.ory.sh/projects/$ORY_ID/tokens/$APIKEY_ID \
    -H "Content-Type: application/json" \
    --cookie "ory_session_ory=$ORY_SESSION"| jq

That's it

With this guide you can make use of the Ory Network projects API, but you can manage Ory Network projects with ease using the powerful Ory CLI and console UI. These tools will provide you with full control of your project in 99% of use cases. You can use the projects API to purge a project or list APIs keys in the console. This will be added to the Ory CLI soon, until then you can use this guide.

Visit the Ory Changelog to keep up to date with improvements on Ory Network and the Ory Open Source ecosystem.

Never miss an article - Subscribe to our newsletter!