Create API key
curl --request POST \
--url https://api.partoo.co/v2/api_keys \
--header 'Content-Type: application/json' \
--header 'x-APIKey: <api-key>' \
--data '
{
"label": "API key name",
"description": "API key for updating business name, and categories.",
"expiration_date": "2022-06-05",
"ip_whitelist": [
"172.16.0.0/12",
"127.0.0.1"
],
"has_restricted_permissions": true,
"permissions": [
"business_edit",
"business_edit_name",
"business_edit_categories"
]
}
'import requests
url = "https://api.partoo.co/v2/api_keys"
payload = {
"label": "API key name",
"description": "API key for updating business name, and categories.",
"expiration_date": "2022-06-05",
"ip_whitelist": ["172.16.0.0/12", "127.0.0.1"],
"has_restricted_permissions": True,
"permissions": ["business_edit", "business_edit_name", "business_edit_categories"]
}
headers = {
"x-APIKey": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-APIKey': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
label: 'API key name',
description: 'API key for updating business name, and categories.',
expiration_date: '2022-06-05',
ip_whitelist: ['172.16.0.0/12', '127.0.0.1'],
has_restricted_permissions: true,
permissions: ['business_edit', 'business_edit_name', 'business_edit_categories']
})
};
fetch('https://api.partoo.co/v2/api_keys', 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://api.partoo.co/v2/api_keys",
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([
'label' => 'API key name',
'description' => 'API key for updating business name, and categories.',
'expiration_date' => '2022-06-05',
'ip_whitelist' => [
'172.16.0.0/12',
'127.0.0.1'
],
'has_restricted_permissions' => true,
'permissions' => [
'business_edit',
'business_edit_name',
'business_edit_categories'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-APIKey: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.partoo.co/v2/api_keys"
payload := strings.NewReader("{\n \"label\": \"API key name\",\n \"description\": \"API key for updating business name, and categories.\",\n \"expiration_date\": \"2022-06-05\",\n \"ip_whitelist\": [\n \"172.16.0.0/12\",\n \"127.0.0.1\"\n ],\n \"has_restricted_permissions\": true,\n \"permissions\": [\n \"business_edit\",\n \"business_edit_name\",\n \"business_edit_categories\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-APIKey", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.partoo.co/v2/api_keys")
.header("x-APIKey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"label\": \"API key name\",\n \"description\": \"API key for updating business name, and categories.\",\n \"expiration_date\": \"2022-06-05\",\n \"ip_whitelist\": [\n \"172.16.0.0/12\",\n \"127.0.0.1\"\n ],\n \"has_restricted_permissions\": true,\n \"permissions\": [\n \"business_edit\",\n \"business_edit_name\",\n \"business_edit_categories\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.partoo.co/v2/api_keys")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-APIKey"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"label\": \"API key name\",\n \"description\": \"API key for updating business name, and categories.\",\n \"expiration_date\": \"2022-06-05\",\n \"ip_whitelist\": [\n \"172.16.0.0/12\",\n \"127.0.0.1\"\n ],\n \"has_restricted_permissions\": true,\n \"permissions\": [\n \"business_edit\",\n \"business_edit_name\",\n \"business_edit_categories\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": 3245,
"label": "API key name",
"description": "API key for updating business name, and categories.",
"user_id": "5309c3a237bbc544d8e26737",
"user_name": "Perceval de Galles",
"user_role": "BUSINESS_MANAGER",
"user_type": "user",
"disabled": false,
"expiration_date": "2022-06-05",
"last_used_at": "2019-08-22 11:46:38.914467+00",
"created_by": "5309c3a237bbc544d8e26737",
"created_by_name": "John Smith",
"created_at": "2018-03-12 11:49:03.399475+00",
"revoked_by": "5309c3a237bbc544d8e26737",
"revoked_by_name": "John Smith",
"revoked_at": "2020-10-20 11:46:38.914467+00",
"ip_whitelist": [
"172.16.0.0/12",
"127.0.0.1"
],
"has_restricted_permissions": true,
"permissions": [
"business_edit",
"business_edit_name",
"business_edit_categories"
]
}{
"errors": {
"json": {}
}
}{
"errors": {
"authentication": "User not authenticated"
}
}{
"errors": {
"authorization": "Operation not allowed"
}
}ApiKeys
Create API key
This endpoint lets you create a new API key.
For more details on how API keys work, and how to handle them securely, see the Security and API Key Usage guide.
POST
/
api_keys
Create API key
curl --request POST \
--url https://api.partoo.co/v2/api_keys \
--header 'Content-Type: application/json' \
--header 'x-APIKey: <api-key>' \
--data '
{
"label": "API key name",
"description": "API key for updating business name, and categories.",
"expiration_date": "2022-06-05",
"ip_whitelist": [
"172.16.0.0/12",
"127.0.0.1"
],
"has_restricted_permissions": true,
"permissions": [
"business_edit",
"business_edit_name",
"business_edit_categories"
]
}
'import requests
url = "https://api.partoo.co/v2/api_keys"
payload = {
"label": "API key name",
"description": "API key for updating business name, and categories.",
"expiration_date": "2022-06-05",
"ip_whitelist": ["172.16.0.0/12", "127.0.0.1"],
"has_restricted_permissions": True,
"permissions": ["business_edit", "business_edit_name", "business_edit_categories"]
}
headers = {
"x-APIKey": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-APIKey': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
label: 'API key name',
description: 'API key for updating business name, and categories.',
expiration_date: '2022-06-05',
ip_whitelist: ['172.16.0.0/12', '127.0.0.1'],
has_restricted_permissions: true,
permissions: ['business_edit', 'business_edit_name', 'business_edit_categories']
})
};
fetch('https://api.partoo.co/v2/api_keys', 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://api.partoo.co/v2/api_keys",
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([
'label' => 'API key name',
'description' => 'API key for updating business name, and categories.',
'expiration_date' => '2022-06-05',
'ip_whitelist' => [
'172.16.0.0/12',
'127.0.0.1'
],
'has_restricted_permissions' => true,
'permissions' => [
'business_edit',
'business_edit_name',
'business_edit_categories'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-APIKey: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.partoo.co/v2/api_keys"
payload := strings.NewReader("{\n \"label\": \"API key name\",\n \"description\": \"API key for updating business name, and categories.\",\n \"expiration_date\": \"2022-06-05\",\n \"ip_whitelist\": [\n \"172.16.0.0/12\",\n \"127.0.0.1\"\n ],\n \"has_restricted_permissions\": true,\n \"permissions\": [\n \"business_edit\",\n \"business_edit_name\",\n \"business_edit_categories\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-APIKey", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.partoo.co/v2/api_keys")
.header("x-APIKey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"label\": \"API key name\",\n \"description\": \"API key for updating business name, and categories.\",\n \"expiration_date\": \"2022-06-05\",\n \"ip_whitelist\": [\n \"172.16.0.0/12\",\n \"127.0.0.1\"\n ],\n \"has_restricted_permissions\": true,\n \"permissions\": [\n \"business_edit\",\n \"business_edit_name\",\n \"business_edit_categories\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.partoo.co/v2/api_keys")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-APIKey"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"label\": \"API key name\",\n \"description\": \"API key for updating business name, and categories.\",\n \"expiration_date\": \"2022-06-05\",\n \"ip_whitelist\": [\n \"172.16.0.0/12\",\n \"127.0.0.1\"\n ],\n \"has_restricted_permissions\": true,\n \"permissions\": [\n \"business_edit\",\n \"business_edit_name\",\n \"business_edit_categories\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": 3245,
"label": "API key name",
"description": "API key for updating business name, and categories.",
"user_id": "5309c3a237bbc544d8e26737",
"user_name": "Perceval de Galles",
"user_role": "BUSINESS_MANAGER",
"user_type": "user",
"disabled": false,
"expiration_date": "2022-06-05",
"last_used_at": "2019-08-22 11:46:38.914467+00",
"created_by": "5309c3a237bbc544d8e26737",
"created_by_name": "John Smith",
"created_at": "2018-03-12 11:49:03.399475+00",
"revoked_by": "5309c3a237bbc544d8e26737",
"revoked_by_name": "John Smith",
"revoked_at": "2020-10-20 11:46:38.914467+00",
"ip_whitelist": [
"172.16.0.0/12",
"127.0.0.1"
],
"has_restricted_permissions": true,
"permissions": [
"business_edit",
"business_edit_name",
"business_edit_categories"
]
}{
"errors": {
"json": {}
}
}{
"errors": {
"authentication": "User not authenticated"
}
}{
"errors": {
"authorization": "Operation not allowed"
}
}Authorizations
Body
application/json
Request body schema for creating or updating an API key
Response
Created
Base API Key object with common properties
Was this page helpful?