cURL
curl -X POST \
/user/api-tokens \
--header "Content-Type: application/json" \
--header "Authorization: Bearer <token>" \
--data '{
"description": "My API token",
"expiresAt": "2021-01-01T00:00:00+00:00"
}'import requests
url = "https://coreapi.io/user/api-tokens"
payload = {
"description": "My API token",
"expiresAt": "2021-01-01T00:00:00+00:00"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({description: 'My API token', expiresAt: '2021-01-01T00:00:00+00:00'})
};
fetch('https://coreapi.io/user/api-tokens', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://coreapi.io/user/api-tokens",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'description' => 'My API token',
'expiresAt' => '2021-01-01T00:00:00+00:00'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"id": "A1B2C3D4E5F6G7H8I9J0",
"token": "api_A1B2C3D4E5F6G7H8I9J0",
"description": "My API token",
"expiresAt": "2021-01-01T00:00:00+00:00"
}Api Tokens
Create api token
Create a new api token for this user. This token can be used to authenticate against the API. The token has the same privileges as the current user account, assigned to tenant.
Required permissions:user:api-token:writePOST
/
user
/
api-tokens
cURL
curl -X POST \
/user/api-tokens \
--header "Content-Type: application/json" \
--header "Authorization: Bearer <token>" \
--data '{
"description": "My API token",
"expiresAt": "2021-01-01T00:00:00+00:00"
}'import requests
url = "https://coreapi.io/user/api-tokens"
payload = {
"description": "My API token",
"expiresAt": "2021-01-01T00:00:00+00:00"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({description: 'My API token', expiresAt: '2021-01-01T00:00:00+00:00'})
};
fetch('https://coreapi.io/user/api-tokens', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://coreapi.io/user/api-tokens",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'description' => 'My API token',
'expiresAt' => '2021-01-01T00:00:00+00:00'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"id": "A1B2C3D4E5F6G7H8I9J0",
"token": "api_A1B2C3D4E5F6G7H8I9J0",
"description": "My API token",
"expiresAt": "2021-01-01T00:00:00+00:00"
}Autorisierungen
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/jsontext/html
The new ApiToken resource
War diese Seite hilfreich?