createApiKey
Create a company API key
createApiKey(
input: CreateApiKeyInput!
): CreateApiKeyPayload
Arguments
createApiKey.input ● CreateApiKeyInput! non-null input
Parameters for CreateApiKey
Type
CreateApiKeyPayload object
Autogenerated return type of CreateApiKey.
Example request
This generated mutation uses placeholders for required values. Replace them with values available to your API key before running it.
Before you run it
Run the companies query first and use data.companies.collection[].id as companyId.
- cURL
- JavaScript
- Python
curl --request POST https://api.convisoappsec.com/graphql \
--header "x-api-key: $CONVISO_API_KEY" \
--header "content-type: application/json" \
--data '{"query":"mutation MutateCreateApiKey($input: CreateApiKeyInput!) {\n createApiKey(input: $input) { apiKey { id name status } clientMutationId token }\n}","variables":{"input":{"companyId":"<company_id>","name":"example","type":"SERVICE","expiresAt":"<ISO8601DateTime>"}}}'
const response = await fetch('https://api.convisoappsec.com/graphql', {
method: 'POST',
headers: {
'content-type': 'application/json',
'x-api-key': process.env.CONVISO_API_KEY,
},
body: JSON.stringify({
query: "mutation MutateCreateApiKey($input: CreateApiKeyInput!) {\n createApiKey(input: $input) { apiKey { id name status } clientMutationId token }\n}",
variables: {
"input": {
"companyId": "<company_id>",
"name": "example",
"type": "SERVICE",
"expiresAt": "<ISO8601DateTime>"
}
},
}),
});
const { data, errors } = await response.json();
if (errors) throw new Error(errors.map(({ message }) => message).join(', '));
console.log(data);
import json
import os
import requests
response = requests.post(
'https://api.convisoappsec.com/graphql',
headers={
'content-type': 'application/json',
'x-api-key': os.environ['CONVISO_API_KEY'],
},
json={
'query': "mutation MutateCreateApiKey($input: CreateApiKeyInput!) {\n createApiKey(input: $input) { apiKey { id name status } clientMutationId token }\n}",
'variables': json.loads("{\"input\":{\"companyId\":\"<company_id>\",\"name\":\"example\",\"type\":\"SERVICE\",\"expiresAt\":\"<ISO8601DateTime>\"}}"),
},
timeout=30,
)
response.raise_for_status()
payload = response.json()
if payload.get('errors'):
raise RuntimeError(payload['errors'])
print(payload['data'])
Contribute to the Docs
Found something outdated or missing? Help us improve the documentation with a quick suggestion or edit.
How to contribute