This endpoint writes JSON values to the distributed ledger. The body is treated as an object of key-value pairs, with the values getting written to the distributed ledger and replaced with tokens in the response. There is a per-request limit of 1024 key-value pairs, with no value allowed to be greater than 3kb in size. If the size of the batch is greater than 500kb, the request will be rejected. The PostBatch operation offers read-after-write consistency and each token is available when the response is sent.

Request

FieldTypeDescription
Content-TypeStringapplication/json
AuthorizationStringALTR API's authorization protocol relies on a properly formatted authorization header. The accepted format is: "ALTR " + api_key + ":" + signature. signature is a base64-encoded, SHA-256 hash that uses the API key's secret as the key for the hash function. The payload being hashed must follow the format: HTTP-METHOD + "\n" + RESOURCE + "\n" + DATE + "\n". DATE must match X-ALTR-DATE, and RESOURCE must be empty for a POST request. An example payload for a POST request is: "POST\n\n01-01-1970 00:00:00\n"
X-ALTR-DATEDateThe datetime used in the authorization signature. If this is more than 15 minutes past the server's internal clock, the request will be rejected.
Content-LengthNumberSize of the request. Depending on application, the request will be rejected with a 403 if the request is over 8KB or a 509 status code if the request if over 500kb.

Response

FieldTypeDescription
X-Bytes-ConsumedNumberThe number of bytes written to the distributed ledger and counted against the Key's organization. The number may differ from the Content-Length header becuase the string representation of the data is written to the distributed ledger.
X-Overflow-DataBooleanThis flag will be set if any single value is greater than 3kb, or the entire batch is greater than 500kb.
date = new Date();
payload = 'POST\n\n' + date + '\n';
API_KEY = <your API key>;
SECRET = <your API secret>;
{
    "X-ALTR-DATE": date,
    "Authorization": "ALTR " + API_KEY + ":" + base64(hmac-sha256(payload, SECRET)),
    "Content-Type": "application/json",
    "Content-Length": 12345
}
{
    "X-BYTES-CONSUMED": 12345,
    "X-OVERFLOW-DATA": true
}

200

FieldTypeDescription
tokenStringOn success, the JSON values given in the body will be replaced with the tokens. If any single value is greater than 3kb, X-Overflow-Data will be set to true and the value will be set to null in the response
HTTP/1.1 200 OK
{
    "key-1": "token1",
    "key-2": "token2",
    "overflow-key": null
}

Error Codes

CodeNameDescription
400bad_requestOrganization data cap exceeded.
401unauthorizedThe API key could not be authenticated.
403forbiddenAPI key does not have write permissions.
503internal_errorThe web server encountered an unexpected error.
509bandwithLimit Exceeded Request exceeded 500kb limit. X-Overflow-Data header will be set to true.
HTTP/1.1 503 Internal Server Error
{
  "success": false,
  "response": {
      "error_type": "internal_error",
      "error_message": "Unable to process request at this time."
  }
}
HTTP/1.1 400 Bad Request
{
  "success": false,
  "response": {
      "error_type": "bad_request",
      "error_message": "Organization data cap exceeded"
  }
}
HTTP/1.1 400 Bad Request
{
  "success": false,
  "response": {
      "error_type": "bad_request",
      "error_message": "Invalid JSON detected. Failed unique key check"
  }
}
HTTP/1.1 401 Authentication Required
{
  "success": false,
  "response": {
      "error_type": "unauthorized",
      "error_message":  "API key must be included in header."
  }
}
HTTP/1.1 403 Forbidden
{
  "success": false,
  "response": {
      "error_type": "forbidden",
      "error_message":  "API key does not have write permission."
  }
}