Learn how to create a private API key with a scope.
A scope allows you to restrict access for third parties using a private API key. Adding a scope helps you protect your and your customers’ data by limiting what third parties can access.
Before you begin
See the available scopes for each API. You can set each scopes with one of the following permissions:
Read-only : Only allows third parties to view all data associated with the endpoint.
Full : Allows third parties to create, delete, or make changes to anything associated with that endpoint.
Custom : Allows you to decide how much access to give the third party.
Note that you cannot add a scope to an existing private key, which have full access by default. You also cannot edit a private API key after it’s been created. If you need to remove access to a key based on its current scope, delete it and then create a new key with the correct scope.
If you're not sure which scope or permissions you need, please contact a developer or reach out to a Klaviyo partner for help, as the answer depends on your use case.
Create a private API key
4. Click Create Private API Key.
5. Name the API key.
6. Choose the scope you want to give the API key:
Read-only
Full
Custom
7. Select Create.
Now, when you share a private API key, the third party will only have access to the information you defined in the scope.
Using queries
Include
Note that if you try to use the include
query, you will have to change the format from what’s listed above.
For example, the profiles endpoint is /api/profiles.
However, if you add the include query parameter (/api/profiles?include=list), you will also need list:read or list:full access, depending on what type of API call you’re making.
Scopes
Using the scopes
parameter, you can create a URL parameter to autofill in what scope access you need for your private API key.
In the scopes query, include a comma-separated list of the scopes you want to preselect.
An example URL is:
https://www.klaviyo.com/create-private-api-key?scopes=campaigns:read,campaigns:write