Preskoči in pojdi v glavno vsebino

API Keys

v Auth
Seznam avtorjev
Objavljeno: 18. jul. 2022|Nazadnje Posodobljeno: 7. mar. 2023

The most common way to use the API is with an API Key.

An API Key can be defined from within Deskpro at Admin -> Apps -> API Keys. You can define as many API keys as you want.

CleanShot 2022-07-18 at 09.43.02@2x.png

Performing API calls with an API keyCopy link to Performing API calls with an API key to clipboard

Here’s an example call made to the helpdesk/discover endpoint:

curl -H "Authorization: key 2:YWK2PGCS8CNW62SR8TBTBKWMY" \ http://example.com/api/v2/me
copy
{ "data": { "auth_method": "api_key", "app_id": null, "person_id": 1, "person": { "id": 1, "...": "..." } }, "meta": {}, "linked": {} }
copy

OptionsCopy link to Options to clipboard

API Key CodeCopy link to API Key Code to clipboard

The Key Code is like a password. You use this in your API requests to authenticate the request.

API Key ContextCopy link to API Key Context to clipboard

Sets the user context for requests using this key, which dictates what actions the key can actually perform. For example, if you set the agent to "Matthew", it means any API request you make with this API key will be run with all the permissions that Matthew normally has.

Machine KeyCopy link to Machine Key to clipboard

A Machine Key is an API key that can be bound to any agent. This makes it possible to specify the agent context at the time you make the API request rather than at the time you make the API key itself. This gives you some flexibility, but also makes the API key rather sensitive because it can potentially be used to do a lot more things.

When using a Machine Key, you specify the agent ID context in a special header called "X-DeskPRO-Agent-ID". E.g.

curl -H "Authorization: key 2:YWK2PGCS8CNW62SR8TBTBKWMY" \ -H "X-DeskPRO-Agent-ID: 4" \ http://example.com/api/v2/me
copy

Allow / Disallow TagsCopy link to Allow / Disallow Tags to clipboard

All API endpoints are tagged (see the API reference for tags). You must specify which tags your API key is allowed to use, and you may optionally disallow specific tags here too. You can use asterisks as wildcards.

The most permissivie API key would be one with an allow tag of * which would match everything.

See here for more information: Access Control with Tags

FAQCopy link to FAQ to clipboard

So the things I can do with the API depends on which agent the key is bound to?Copy link to So the things I can do with the API depends on which agent the key is bound to? to clipboard

That's right. The API key inherits all permissions from the agent it's bound to. For example, if an agent can't access tickets assigned to other agents, then using the API to do that will fail as well.

How do I create a "super" API key that can do anything?Copy link to How do I create a "super" API key that can do anything? to clipboard

This is typically done by creating an API key bound to an administrator user who has permissions to do everything.

Can I lock-down an API key so it can only do specific things?Copy link to Can I lock-down an API key so it can only do specific things? to clipboard

Yes, this is done by allowing specific tags. See the "Allow / Disallow Tags" section above.

UporabnoNeuporabno

0 od skupaj 1 oseb je ocenilo to stran kot uporabno.

naslednja stranAccess Control with Tags

Pred objavo komentarja se moraš prijaviti.