Skip to content

Get the configuration file rules (pbx)

get /configuration-import/rules

Returns the rules a configuration file from another system (kind external) must follow. Read them before you write a converter, and again when they change.

The answer is a JSON Schema for the file and for each kind of record, so any JSON Schema validator can check a file before you send it (version 2020-12 of the standard, named in $schema). It adds these parts:

  • x-cockpit-rules: the rules a JSON Schema cannot express, for example that a schedule step needs both times unless it is a specific period.
  • x-cockpit-references: which column points at which kind of record.
  • x-cockpit-error-codes: every error code the check can answer, with its meaning.
  • $defs.call_flow_step.x-cockpit-options: the options keys of each call flow step type.
  • x-cockpit-pbx-features: whether voicemail, language variants and call recording are on for the PBX of your API key, because some rules depend on them. Nothing else about the PBX is returned. The copy in api-guides/configuration-import/rules.json has no such part.

A column whose meaning is not obvious from its name has a description.

Caching. The answer has an ETag and Cache-Control: private, max-age=3600. The tag changes when the rules or the PBX's features change. Send it back in If-None-Match to get 304 while nothing changed.

Needs the configuration-import scope. Rate limit: 30 requests per minute per PBX (429 with Retry-After). Answers 503 while configuration versions are switched off.

HTTP: IntegrationApiKey

API key created on the Cockpit Integrations page (an "API key" integration). It is a bearer token owned by the customer's PBX and limited to the scopes selected when the key was created (e.g. phone-numbers, push-configuration).

Send it in the Authorization header:

Authorization: Bearer <api_key>

Manage keys (create / reveal / revoke) from Integrations → New integration → API key.

HTTP Authorization Scheme
bearer
accept header · string
example: application/json
If-None-Match header · string
The `ETag` of the copy you hold.

Responses

The rule set.
Response schema
Free-form object
Not modified. The rules are the ones the `If-None-Match` tag names. The response has no body.
Response schema
No response body.
Unauthenticated. The `Authorization: Bearer <token>` header was missing, malformed, or names a token that has been revoked or deleted.
Response schema
messagestring
Forbidden. The bearer token authenticated successfully but does not carry the scope this endpoint requires. Re-create the Integrations API key with the missing scope selected (Integrations > New integration > API key). On a write with a user bearer token, the user lacks the Cockpit permission the same change needs (the message names it).
Response schema
messagestring
Too Many Requests. The rate limit for this action has been exceeded. Retry after the window indicated by the Retry-After header.
Response schema
messagestring
Service Unavailable. Configuration versions are switched off on this installation, so configuration import is not available. Nothing was read or stored.
Response schema
messagestring
get https://cockpit.voxbi.com/api/v1/configuration-import/rules
Base URL
Request sample
curl -X GET 'https://cockpit.voxbi.com/api/v1/configuration-import/rules' \
  -H 'Authorization: Bearer YOUR_TOKEN'
const response = await fetch('https://cockpit.voxbi.com/api/v1/configuration-import/rules', {
  method: 'GET',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': `Bearer ${YOUR_TOKEN}`,
  },
});

const data = await response.json();
console.log(data);
import requests

response = requests.get('https://cockpit.voxbi.com/api/v1/configuration-import/rules',
    headers={'Authorization': f'Bearer {YOUR_TOKEN}'}
)
response.raise_for_status()
data = response.json()
print(data)
<?php
$context = stream_context_create([
    'http' => [
        'method'  => 'GET',
        'header'  => "Content-Type: application/json\r\nAuthorization: Bearer YOUR_TOKEN",
    ],
]);

$response = file_get_contents('https://cockpit.voxbi.com/api/v1/configuration-import/rules', false, $context);
$data = json_decode($response, true);
print_r($data);
{ … }
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "urn:cockpit:configuration-import:rules:1",
"title": "PBX configuration file: rules for files from other systems",
"x-cockpit-rules-version": 1,
"type": "object",
"required": [ … ],
"format",
"version",
"schema_version",
"kind",
"rules",
"pbx_id",
"source",
"snapshot",
"files",
"notes",
"data"
],
"x-cockpit-pbx-features": { … },
"call_recording": true,
"language_variants": false,
"voicemail": false
},
"x-cockpit-entities": { … },
"extension": "Extension",
"group": "Group"
},
"x-cockpit-error-codes": { … }
"column.required": "A value is required for the column."
}
}
ETag string
Changes when the rules or the PBX's features change.
example: "5d41402abc4b2a76b9719d911017c592"
Cache-Control string
example: max-age=3600, private
No example for this status.
ETag string
example: "5d41402abc4b2a76b9719d911017c592"
{ … }
"message": "Unauthenticated."
}
Content-Type string
example: application/json
{ … }
"message": "Invalid ability provided."
}
Content-Type string
example: application/json
{ … }
"message": "Too Many Attempts."
}
Retry-After integer
Seconds to wait before retrying.
example: 60
Content-Type string
example: application/json
{ … }
"message": "Configuration import is not available on this system: configuration versions are switched off."
}