Tag Creation API
curl --request POST \
--url https://api.pazy.io/v1.0/tagimport requests
url = "https://api.pazy.io/v1.0/tag"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.pazy.io/v1.0/tag', 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.pazy.io/v1.0/tag",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.pazy.io/v1.0/tag"
req, _ := http.NewRequest("POST", url, nil)
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.pazy.io/v1.0/tag")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.pazy.io/v1.0/tag")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodyTags APIs
Tag Creation API
Create a new organization tag of a given data type
Tag Creation API
curl --request POST \
--url https://api.pazy.io/v1.0/tagimport requests
url = "https://api.pazy.io/v1.0/tag"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.pazy.io/v1.0/tag', 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.pazy.io/v1.0/tag",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.pazy.io/v1.0/tag"
req, _ := http.NewRequest("POST", url, nil)
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.pazy.io/v1.0/tag")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.pazy.io/v1.0/tag")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodyAuthentication
All requests require an API key in the request headers. Headers:Authorization: Api-Key YOUR_API_KEY
Content-Type: application/json
Request
Content-Type:application/json
Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Name of the tag (1–64 characters). It is converted to a URL-safe slug, which becomes the tag’s id |
dataType | string | Yes | Data type of the tag. One of DROPDOWN, VARCHAR, NUMBER, DATETIME |
description | string | No | Description of the tag (1–1024 characters) |
Data Type Values
| Value | Description |
|---|---|
DROPDOWN | Tag with a fixed set of selectable values. Add values to it with the Tag Value Creation API |
VARCHAR | Free-text value |
NUMBER | Numeric value |
DATETIME | Date / time value |
Code Examples
curl -X POST https://api.pazy.io/v1.0/tag \
-H "Authorization: Api-Key YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Cost Center",
"dataType": "DROPDOWN",
"description": "Cost center the expense belongs to"
}'
const response = await fetch('https://api.pazy.io/v1.0/tag', {
method: 'POST',
headers: {
'Authorization': 'Api-Key YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'Cost Center',
dataType: 'DROPDOWN',
description: 'Cost center the expense belongs to'
})
});
const result = await response.json();
import requests
url = "https://api.pazy.io/v1.0/tag"
headers = {
"Authorization": "Api-Key YOUR_API_KEY",
"Content-Type": "application/json"
}
payload = {
"name": "Cost Center",
"dataType": "DROPDOWN",
"description": "Cost center the expense belongs to"
}
response = requests.post(url, headers=headers, json=payload)
result = response.json()
Success Response
HTTP Status:200 OK
Response Fields:
| Field | Type | Description |
|---|---|---|
ok | boolean | Indicates whether the request was successful |
created | boolean | Indicates whether the tag was created |
tag | object | The created tag |
tag.id | string | Slug identifier of the created tag. Use this as tagId in related tag APIs |
Response Example
{
"ok": true,
"created": true,
"tag": {
"id": "cost-center"
}
}
Error Responses
Reserved Tag Name
HTTP Status:400 Bad Request
{
"ok": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "Custom Tag name cannot be one of the reserved tags. Please use a different name"
}
}
Tag Already Exists
HTTP Status:400 Bad Request
{
"ok": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "Tag already exists"
}
}
Validation Error
Returned when a required field is missing ordataType is not one of the allowed values.
HTTP Status: 400 Bad Request
{
"ok": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "Validation failed: /body/dataType: must be equal to one of the allowed values"
}
}
Tag Creation Failed
In the rare case the tag could not be persisted, the response is returned with an HTTP200 OK status, ok: false, and created: false.
HTTP Status: 200 OK
{
"ok": false,
"created": false
}
Access Denied
HTTP Status:403 Forbidden
{
"ok": false,
"error": {
"code": "ACCESS_DENIED",
"message": "Access denied: Only admin and bookkeeper can create this resources"
}
}
Authentication Errors
HTTP Status:401 Unauthorized
{
"ok": false,
"error": {
"code": "MISSING_CREDENTIALS",
"message": "Missing Credentials"
}
}
{
"ok": false,
"error": {
"code": "INVALID_API_KEY",
"message": "Invalid API Key"
}
}
Permission Errors
HTTP Status:403 Forbidden
{
"ok": false,
"error": {
"code": "INSUFFICIENT_PERMISSIONS",
"message": "Permission check failed - PERMISSION_CHECK_FAILED"
}
}
Best Practices
- The tag
nameis normalized into a slug (for example,Cost Centerbecomescost-center) — that slug is returned astag.idand is what you use in other tag APIs - Always check the
createdflag in addition to the HTTP status; a tag-creation failure is returned withok: falseandcreated: falseunder a200 OKstatus - Create a
DROPDOWNtag first, then add its selectable values with the Tag Value Creation API - Access is limited to users with tag create permission and an admin or bookkeeper role
Was this page helpful?