Create allocation rule
curl --request POST \
--url https://api.nops.io/v1/cost-allocation/{id}/rules \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--data '
{
"name": "Production workloads"
}
'import requests
url = "https://api.nops.io/v1/cost-allocation/{id}/rules"
payload = { "name": "Production workloads" }
headers = {
"Idempotency-Key": "<idempotency-key>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Idempotency-Key': '<idempotency-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({name: 'Production workloads'})
};
fetch('https://api.nops.io/v1/cost-allocation/{id}/rules', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.nops.io/v1/cost-allocation/{id}/rules"
payload := strings.NewReader("{\n \"name\": \"Production workloads\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
req.Header.Add("Authorization", "Bearer <token>")
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))
}{
"data": {
"rule": {
"id": "rule-1",
"showbackId": 1,
"name": "Production workloads",
"showbackValue": "Production",
"orderIndex": 0,
"active": true
}
}
}{
"error": {
"code": "forbidden_scope",
"message": "API key is missing required scope: budgets:write",
"request_id": "550e8400-e29b-41d4-a716-446655440000"
}
}{
"error": {
"code": "forbidden_scope",
"message": "API key is missing required scope: budgets:write",
"request_id": "550e8400-e29b-41d4-a716-446655440000"
}
}Cost allocation
Create allocation rule
POST
https://api.nops.io
/
v1
/
cost-allocation
/
{id}
/
rules
Create allocation rule
curl --request POST \
--url https://api.nops.io/v1/cost-allocation/{id}/rules \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--data '
{
"name": "Production workloads"
}
'import requests
url = "https://api.nops.io/v1/cost-allocation/{id}/rules"
payload = { "name": "Production workloads" }
headers = {
"Idempotency-Key": "<idempotency-key>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Idempotency-Key': '<idempotency-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({name: 'Production workloads'})
};
fetch('https://api.nops.io/v1/cost-allocation/{id}/rules', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.nops.io/v1/cost-allocation/{id}/rules"
payload := strings.NewReader("{\n \"name\": \"Production workloads\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
req.Header.Add("Authorization", "Bearer <token>")
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))
}{
"data": {
"rule": {
"id": "rule-1",
"showbackId": 1,
"name": "Production workloads",
"showbackValue": "Production",
"orderIndex": 0,
"active": true
}
}
}{
"error": {
"code": "forbidden_scope",
"message": "API key is missing required scope: budgets:write",
"request_id": "550e8400-e29b-41d4-a716-446655440000"
}
}{
"error": {
"code": "forbidden_scope",
"message": "API key is missing required scope: budgets:write",
"request_id": "550e8400-e29b-41d4-a716-446655440000"
}
}Authorizations
API key from Settings → Security → API Keys. Pass as Authorization: Bearer YOUR_API_KEY.
Headers
Unique key for safe retries on write requests (required, max 64 characters).
Maximum string length:
64Path Parameters
Showback ID
Body
application/json
Required string length:
1 - 256Required string length:
1 - 256Show child attributes
Show child attributes
Available options:
BY_SPEND, CUSTOM_PERCENT, CUSTOM_BY_SPEND, EVENLY Show child attributes
Show child attributes
Show child attributes
Show child attributes
Response
Create allocation rule
JSON object
Was this page helpful?