For the complete documentation index, see llms.txt. This page is also available as Markdown.

🔑Generating an API key

Generate an API key to use the P0 Management API or install P0 via Terraform.

API keys let you authenticate with P0's Management API and integrate P0 into your infrastructure-as-code workflows. A P0 API key carries the full Owner role. You can use an API key to:

Prerequisites

You must have the Owner role in your P0 organization to generate API keys.

Generate an API key

  1. Navigate to P0 Management in the P0 dashboard sidebar.

  2. Expand the API Keys section.

  3. Click Create a new API key.

  4. Enter a descriptive name for the key (for example, "Terraform CI/CD" or "Management API").

  5. Click Submit.

  6. Copy the API key immediately.

The API Keys section in P0 Management showing the Create a new API key dialog

Generate an API key using the API

You can also create, list, and delete API keys programmatically with the Management API. See the API key management API reference for the available endpoints, request and response formats, and authorization requirements.

Using the API key

With the Management API

Include the API key in the Authorization header of your API requests:

With the Terraform provider

Give the API key to the P0 Terraform provider in one of two ways.

Set the P0_API_TOKEN environment variable, and keep the token out of your configuration files:

Or set the api_token attribute on the provider block:

The api_token attribute takes precedence when both are set.

You can use the provider to install integrations and to manage organization settings as code, including role assignments, the access-duration policy, and expiry options. Managing organization settings requires provider version 0.50.0 or later. For the full provider reference, see the P0 Terraform provider documentation.

Best practices

  • Use descriptive names for your API keys to identify their purpose.

  • Rotate keys regularly as part of your security hygiene.

  • Store keys securely using a secrets manager or environment variables. Never commit API keys to version control.

  • Delete unused keys to minimize your attack surface.

Last updated