curl --request POST \
--url https://meterengine.com/v1/billable-metrics \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"aggregation": "<string>",
"code": "<string>",
"event_type": "<string>",
"name": "<string>",
"dimension_properties": [
"<string>"
],
"percentile": 123,
"rounding_mode": "<string>",
"rounding_precision": 6,
"target_property": "<string>",
"unit_size": 123
}
'const url = 'https://meterengine.com/v1/billable-metrics';
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
aggregation: '<string>',
code: '<string>',
event_type: '<string>',
name: '<string>',
dimension_properties: ['<string>'],
percentile: 123,
rounding_mode: '<string>',
rounding_precision: 6,
target_property: '<string>',
unit_size: 123
})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));{
"active_from": "<string>",
"aggregation": "<string>",
"archived_at": "2023-11-07T05:31:56Z",
"code": "<string>",
"dimension_properties": [
"<string>"
],
"event_type": "<string>",
"inactive_from": "<string>",
"name": "<string>",
"percentile": 123,
"rounding_mode": "<string>",
"rounding_precision": 123,
"target_property": "<string>",
"unit_size": 123,
"version": 123
}{
"code": "validation_error",
"message": "서버 내부 오류입니다",
"errors": [
{
"field": "event_type",
"message": "공백일 수 없습니다"
}
]
}{
"code": "validation_error",
"message": "서버 내부 오류입니다",
"errors": [
{
"field": "event_type",
"message": "공백일 수 없습니다"
}
]
}{
"code": "validation_error",
"message": "서버 내부 오류입니다",
"errors": [
{
"field": "event_type",
"message": "공백일 수 없습니다"
}
]
}{
"code": "validation_error",
"message": "서버 내부 오류입니다",
"errors": [
{
"field": "event_type",
"message": "공백일 수 없습니다"
}
]
}{
"code": "validation_error",
"message": "서버 내부 오류입니다",
"errors": [
{
"field": "event_type",
"message": "공백일 수 없습니다"
}
]
}집계 미터 등록
미터를 등록한다. type이 미터의 event_type과 같은 사용량 이벤트가 이 미터의 집계 대상이다.
aggregation은 sum, count, count_distinct, min, max, avg, first, last, median, percentile을 받으며 대소문자를 구분하지 않는다.
count는 전체 이벤트 수이며 target_property를 지정하지 않는다. count_distinct는 대상 속성의 숫자, 문자열, 불리언 고유값 수다.
나머지는 숫자 속성만 집계한다. first와 last는 occurred_at, transaction_id 순서다. median은 50백분위, percentile은 0100의 percentile이 필수다.
집계량을 unit_size(기본 1)로 나눈 뒤 rounding_mode(none, ceil, floor, round)를 rounding_precision(012, 기본 0)에 적용한다.
round는 사사오입이며 none은 유한소수를 그대로 보존하고 순환소수는 유효숫자와 소수 자릿수를 각각 최소 18자리로 보존한다. code는 도입사 안에서 유일하고 등록 뒤 바꿀 수 없다.
같은 이벤트와 속성에 여러 미터를 등록할 수 있다. 각 미터에 단가를 설정하면 각각 청구한다.
curl --request POST \
--url https://meterengine.com/v1/billable-metrics \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"aggregation": "<string>",
"code": "<string>",
"event_type": "<string>",
"name": "<string>",
"dimension_properties": [
"<string>"
],
"percentile": 123,
"rounding_mode": "<string>",
"rounding_precision": 6,
"target_property": "<string>",
"unit_size": 123
}
'const url = 'https://meterengine.com/v1/billable-metrics';
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
aggregation: '<string>',
code: '<string>',
event_type: '<string>',
name: '<string>',
dimension_properties: ['<string>'],
percentile: 123,
rounding_mode: '<string>',
rounding_precision: 6,
target_property: '<string>',
unit_size: 123
})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));{
"active_from": "<string>",
"aggregation": "<string>",
"archived_at": "2023-11-07T05:31:56Z",
"code": "<string>",
"dimension_properties": [
"<string>"
],
"event_type": "<string>",
"inactive_from": "<string>",
"name": "<string>",
"percentile": 123,
"rounding_mode": "<string>",
"rounding_precision": 123,
"target_property": "<string>",
"unit_size": 123,
"version": 123
}{
"code": "validation_error",
"message": "서버 내부 오류입니다",
"errors": [
{
"field": "event_type",
"message": "공백일 수 없습니다"
}
]
}{
"code": "validation_error",
"message": "서버 내부 오류입니다",
"errors": [
{
"field": "event_type",
"message": "공백일 수 없습니다"
}
]
}{
"code": "validation_error",
"message": "서버 내부 오류입니다",
"errors": [
{
"field": "event_type",
"message": "공백일 수 없습니다"
}
]
}{
"code": "validation_error",
"message": "서버 내부 오류입니다",
"errors": [
{
"field": "event_type",
"message": "공백일 수 없습니다"
}
]
}{
"code": "validation_error",
"message": "서버 내부 오류입니다",
"errors": [
{
"field": "event_type",
"message": "공백일 수 없습니다"
}
]
}인증
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
헤더
1~255자 재시도 키. 같은 도입사와 업무 환경에서 같은 키와 같은 본문을 다시 보내면 최초 응답을 상태 코드까지 그대로 돌려준다. 최초 응답을 기한 없이 보관하므로 그 뒤에 고치거나 보관해도 재전송 응답은 바뀌지 않는다.
본문
1111단가를 가르는 이벤트 속성 키. 속성에 따라 단가가 갈리지 않으면 빈 배열
percentile 집계에서만 지정하는 백분위 0~100
단위 변환 후 반올림: none, ceil, floor, round. 기본값은 none
반올림할 소수 자릿수 0~12. 기본값은 0
0 <= x <= 12집계량을 나눌 양수 단위. 기본값은 1
응답
등록된 미터
단가를 가르는 이벤트 속성 키. 속성에 따라 단가가 갈리지 않으면 빈 배열