Authenticate and access the Laravel Cloud API using tokens and credentials.
The Laravel Cloud API uses token-based authentication. You can generate an API token from your Laravel Cloud organization settings. Once you have your token, include it in the Authorization header of your API requests as follows:
You can manage your API tokens from your Laravel Cloud organization settings. Navigate to the API tokens section to create, view, and revoke your tokens.
Navigate to your Laravel Cloud organization settings
Click API tokens in the sidebar
Click the Create API Token button
Enter a descriptive name for your token to help you identify its purpose
Select an expiration period for the token
Click Create to generate your new API token
Copy your API token immediately after you create it. For security reasons, Laravel Cloud displays the token only once. Store it securely and never share it publicly.
To revoke an API token that you no longer need or that may have been compromised, follow these steps:
Navigate to your Laravel Cloud organization settings
Click API tokens in the sidebar
Find the API token you want to revoke in the list
Click the Revoke button next to the token
Confirm your password when prompted
Click Revoke API token to permanently delete the token
You can’t restore a revoked API token. Any applications using the token immediately lose access to the API. If you need continued access, update your applications with a new token before you revoke the old one.
API tokens have configurable expiration periods to help maintain security. When creating a new token, you can choose from the following expiration options:
1 month: recommended for short-term projects or testing
6 months: a good balance between security and convenience
1 year: suitable for long-term integrations
Once a token expires, it’s no longer valid for API requests, and you’ll need to generate a new one. Make sure to update your applications with the new token before the old one expires.
By default, an API token has full access to your organization and can interact with every endpoint, application, and environment. To follow the principle of least privilege, you can scope a token down so it only has the access it needs. Scoping is optional, and you configure it when you create a token.Laravel Cloud provides two independent controls for scoping a token:
Permissions limit which API endpoints the token can access.
Resource scoping limits which applications and environments the token can interact with.
You can apply either control on its own or combine them. A token’s scope is separate from user roles and permissions. A token does not inherit or mirror the access of the user who created it, so you must define its scope explicitly.
Permissions determine which API endpoints a token can call. When you assign permissions, the token can perform only the actions you select, and Cloud rejects requests to any other endpoint.For example, you might grant a token permission to view deployments and trigger new ones while withholding the ability to manage environment variables or delete resources. That combination lets you issue a token for a continuous integration pipeline
that can deploy your application without exposing your secrets.
Resource scoping determines which applications and environments a token can interact with. When you scope a token to specific resources, Cloud rejects requests to any application or environment outside that scope.Resource scoping and permissions work together. For example, you can create a token that has permission to trigger deployments and is scoped to only your staging environment, so the token can deploy to staging but never to production.
Create a separate, tightly scoped token for each integration or automation rather than reusing one broadly scoped token. If a token is ever compromised, it can reach only the endpoints and resources you granted, and you can revoke it without disrupting your other integrations.
Was this page helpful?
Assistant
Responses are generated using AI and may contain mistakes.