Create a score definition
const url = 'http://localhost:8080/api/v1/projects/example/score-definitions';const options = { method: 'POST', headers: { cookie: 'cetra_session=<cetra_session>', 'Content-Type': 'application/json' }, body: '{"categories":[{"label":"example","value":1}],"data_type":"numeric","description":"example","direction":"higher","max_value":1,"min_value":1,"name":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url http://localhost:8080/api/v1/projects/example/score-definitions \ --header 'Content-Type: application/json' \ --cookie cetra_session=<cetra_session> \ --data '{ "categories": [ { "label": "example", "value": 1 } ], "data_type": "numeric", "description": "example", "direction": "higher", "max_value": 1, "min_value": 1, "name": "example" }'Project members and above. API keys cannot call it.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Project UUID, URL-encoded org-slug/project-slug, or current.
Request Bodyrequired
Section titled “Request Bodyrequired”POST /api/v1/projects/{project}/score-definitions body.
object
Labels of a categorical score: 1 to 100, unique. Only for categorical scores.
One label of a categorical score definition.
object
The label, 1 to 255 bytes.
Numeric value of the label. Omitted when the label has none.
Score data type. Immutable once created.
What the score means, at most 1 000 characters.
Which way the score should move to be good. Omitted means none. higher and lower
need a numeric range or a value on every category, and are refused on text.
Highest allowed value. Only for numeric scores, above min_value.
Lowest allowed value. Only for numeric scores.
Score name, 1 to 255 bytes after trimming.
Responses
Section titled “Responses”The created score definition.
A named score shape. Archived definitions are kept but not checked against.
object
When the definition was archived. Omitted while it is live. JSON is RFC 3339.
Labels of a categorical score. Empty otherwise.
One label of a categorical score definition.
object
The label, 1 to 255 bytes.
Numeric value of the label. Omitted when the label has none.
Creation time. JSON is RFC 3339.
Score data type. Immutable.
What the score means. Omitted when unset.
Which way the score should move to be good. none when unset.
Definition id.
Highest allowed value of a numeric score. Omitted when unset.
Lowest allowed value of a numeric score. Omitted when unset.
Score name, unique among live definitions of the project.
Last change time. JSON is RFC 3339.
Example
{ "data_type": "numeric", "direction": "higher"}The request is malformed or a filter is invalid.
RFC 7807 problem document.
Spec 09 § Conventions.
object
Machine-readable error code.
Extra explanation. Omitted when absent.
Field errors. Omitted when empty, because RFC 7807 clients expect the member to be absent.
One field that failed validation.
Spec 09 § Conventions.
object
Request field, query parameter, or expression the error refers to.
What is wrong with the field.
Location inside the field value, for filter and SQL errors.
object
1-based column number, in characters.
1-based line number, in characters.
HTTP status code.
Short human-readable summary, the reason phrase of status.
Problem type URI. Always about:blank in this version.
Example
{ "code": "bad_request"}No credentials, or the credentials are invalid.
RFC 7807 problem document.
Spec 09 § Conventions.
object
Machine-readable error code.
Extra explanation. Omitted when absent.
Field errors. Omitted when empty, because RFC 7807 clients expect the member to be absent.
One field that failed validation.
Spec 09 § Conventions.
object
Request field, query parameter, or expression the error refers to.
What is wrong with the field.
Location inside the field value, for filter and SQL errors.
object
1-based column number, in characters.
1-based line number, in characters.
HTTP status code.
Short human-readable summary, the reason phrase of status.
Problem type URI. Always about:blank in this version.
Example
{ "code": "bad_request"}The credentials do not allow this operation, or the organization’s plan does not include it (code plan_required).
RFC 7807 problem document.
Spec 09 § Conventions.
object
Machine-readable error code.
Extra explanation. Omitted when absent.
Field errors. Omitted when empty, because RFC 7807 clients expect the member to be absent.
One field that failed validation.
Spec 09 § Conventions.
object
Request field, query parameter, or expression the error refers to.
What is wrong with the field.
Location inside the field value, for filter and SQL errors.
object
1-based column number, in characters.
1-based line number, in characters.
HTTP status code.
Short human-readable summary, the reason phrase of status.
Problem type URI. Always about:blank in this version.
Example
{ "code": "bad_request"}The resource does not exist.
RFC 7807 problem document.
Spec 09 § Conventions.
object
Machine-readable error code.
Extra explanation. Omitted when absent.
Field errors. Omitted when empty, because RFC 7807 clients expect the member to be absent.
One field that failed validation.
Spec 09 § Conventions.
object
Request field, query parameter, or expression the error refers to.
What is wrong with the field.
Location inside the field value, for filter and SQL errors.
object
1-based column number, in characters.
1-based line number, in characters.
HTTP status code.
Short human-readable summary, the reason phrase of status.
Problem type URI. Always about:blank in this version.
Example
{ "code": "bad_request"}The request conflicts with the current state.
RFC 7807 problem document.
Spec 09 § Conventions.
object
Machine-readable error code.
Extra explanation. Omitted when absent.
Field errors. Omitted when empty, because RFC 7807 clients expect the member to be absent.
One field that failed validation.
Spec 09 § Conventions.
object
Request field, query parameter, or expression the error refers to.
What is wrong with the field.
Location inside the field value, for filter and SQL errors.
object
1-based column number, in characters.
1-based line number, in characters.
HTTP status code.
Short human-readable summary, the reason phrase of status.
Problem type URI. Always about:blank in this version.
Example
{ "code": "bad_request"}Too many requests.
RFC 7807 problem document.
Spec 09 § Conventions.
object
Machine-readable error code.
Extra explanation. Omitted when absent.
Field errors. Omitted when empty, because RFC 7807 clients expect the member to be absent.
One field that failed validation.
Spec 09 § Conventions.
object
Request field, query parameter, or expression the error refers to.
What is wrong with the field.
Location inside the field value, for filter and SQL errors.
object
1-based column number, in characters.
1-based line number, in characters.
HTTP status code.
Short human-readable summary, the reason phrase of status.
Problem type URI. Always about:blank in this version.
Example
{ "code": "bad_request"}