사용량 이벤트 수집
curl --request POST \
--url https://meterengine.com/v1/events \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"customer_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"properties": {},
"timestamp": "2023-11-07T05:31:56Z",
"transaction_id": "<string>",
"type": "<string>"
}
'const url = 'https://meterengine.com/v1/events';
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
customer_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
properties: {},
timestamp: '2023-11-07T05:31:56Z',
transaction_id: '<string>',
type: '<string>'
})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));{
"duplicate": true,
"transaction_id": "<string>"
}{
"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": "공백일 수 없습니다"
}
]
}{
"code": "validation_error",
"message": "서버 내부 오류입니다",
"errors": [
{
"field": "event_type",
"message": "공백일 수 없습니다"
}
]
}이벤트
사용량 이벤트 수집
사용량 이벤트 한 건을 저장한다. transaction_id가 같은 이벤트를 다시 보내면 저장하지 않고 처음 저장한 이벤트를 유지한다. 이때도 응답은 200이고 duplicate가 true다. 응답을 받지 못했으면 같은 transaction_id로 다시 보내면 된다. properties는 키나 문자열 값에 NUL 문자나 짝이 없는 UTF-16 서로게이트가 있거나 숫자가 소수점 앞 131072자리나 소수점 뒤 16383자리를 넘으면 거절하고, 그 밖의 내용은 검증하지 않는다. 키 순서와 공백은 보존되지 않고, 숫자는 정수와 소수 모두 자릿수가 잘리지 않는다. timestamp는 이벤트가 발생한 시각이고 조회 응답에서는 occurred_at으로 나온다. received_at은 서버가 받은 시각이며 요청에 실어도 무시된다. timestamp가 서버의 수집 판정 시각보다 35일 넘게 과거이면 받지 않는다. 1일은 24시간이며, 정확히 35일 전인 이벤트는 받는다. 이미 저장된 transaction_id면 timestamp가 받는 기간 밖이어도 거절하지 않고 duplicate=true로 답한다.
POST
/
v1
/
events
사용량 이벤트 수집
curl --request POST \
--url https://meterengine.com/v1/events \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"customer_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"properties": {},
"timestamp": "2023-11-07T05:31:56Z",
"transaction_id": "<string>",
"type": "<string>"
}
'const url = 'https://meterengine.com/v1/events';
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
customer_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
properties: {},
timestamp: '2023-11-07T05:31:56Z',
transaction_id: '<string>',
type: '<string>'
})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));{
"duplicate": true,
"transaction_id": "<string>"
}{
"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": "공백일 수 없습니다"
}
]
}{
"code": "validation_error",
"message": "서버 내부 오류입니다",
"errors": [
{
"field": "event_type",
"message": "공백일 수 없습니다"
}
]
}인증
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
본문
application/json