Use JSON ({RFC-7159}[RFC 7159]) to represent structured (resource) data passed with HTTP requests and responses as body payload. The JSON payload must use a JSON object as top-level data structure (if possible) to allow for future extension. This also applies to collection resources, where you ad-hoc would use an array — see also [110].
Additionally, the JSON payload must comply to the more restrictive Internet JSON ({RFC-7493}[RFC 7493]), particularly
-
{RFC-7493}#section-2.1[Section 2.1] on encoding of characters, and
-
{RFC-7493}#section-2.3[Section 2.3] on object constraints.
As a consequence, a JSON payload must
-
use {RFC-7493}#section-2.1[
UTF-8
encoding] -
consist of {RFC-7493}#section-2.1[valid Unicode strings], i.e. must not contain non-characters or surrogates, and
-
contain only {RFC-7493}#section-2.3[unique member names] (no duplicate names).
You should use standard media types (defined in {media-types}[media type registry]
of Internet Assigned Numbers Authority (IANA)) as content-type
(or accept
) header
information. More specifically, for JSON payload you should use the standard media type
application/json
(or application/problem+json
for [176]).
You should avoid using custom media types like application/x.sailpoint.article+json
.
Custom media types beginning with x
bring no advantage compared to the
standard media type for JSON, and make automated processing more difficult.
Exposing binary data using an alternative media type is generally preferred. See the rule above.
If an alternative content representation is not desired then binary data should
be embedded into the JSON document as a base64url
-encoded string property
following {RFC-7493}#section-4.4[RFC 7493 Section 4.4].
JSON Schema
and OpenAPI
define several data formats, e.g. date
, time
, email
, and url
, based on ISO and IETF standards.
The following table lists these formats including additional formats useful in an e-commerce environment.
You should use these formats, whenever applicable.
type |
format |
Specification | Example |
---|---|---|---|
|
|
||
|
|
||
|
|
||
|
{IEEE-754-2008}[IEEE 754-2008] |
|
|
|
{IEEE-754-2008}[IEEE 754-2008] |
|
|
|
|
||
|
{BCP47}[BCP 47] |
|
|
|
|
{RFC-7493}[RFC 7493] |
|
|
{RFC-3339}[RFC 3339] |
|
|
|
{RFC-3339}[RFC 3339] |
|
|
|
|
{RFC-5322}[RFC 5322] |
|
|
|
{GTIN}[GTIN] |
|
|
|
{RFC-1034}[RFC 1034] |
|
|
|
{RFC-2673}[RFC 2673] |
|
|
|
{RFC-2673}[RFC 2673] |
|
|
{ISO-3166-1-a2}[ISO 3166-1 alpha-2] |
|
|
|
{ISO-4217}[ISO 4217] |
|
|
|
{ISO-639-1}[ISO 639-1] |
|
|
|
|
{RFC-6901}[RFC 6901] |
|
|
|
|
|
|
|
{ECMA-262}[ECMA 262] |
|
|
{RFC-3339}[RFC 3339] |
|
|
|
|
{RFC-3986}[RFC 3986] |
|
|
|
{RFC-6570}[RFC 6570] |
|
|
{RFC-4122}[RFC 4122] |
|
Remark: Please note that this list of standard data formats is not exhaustive and everyone is encouraged to propose additions.
Read more about date and time format in [126].
Use the following standard formats for country, language and currency codes:
-
Country codes: {ISO-3166-1-a2}[ISO 3166-1-alpha2] two letter country codes
-
Hint: It is "GB", not "UK", even though "UK" has seen some use at sailpoint
-
-
Language codes: {ISO-639-1}[ISO 639-1] two letter language codes
-
Language variant tags: {BCP47}[BCP 47]
-
It is a compatible extension of {ISO-639-1}[ISO 639-1], providing additional information for language usage, like region (using {ISO-3166-1-a2}[ISO 3166-1]), variant, script and others.
-
-
Currency codes: {ISO-4217}[ISO 4217] three letter currency codes
Whenever an API defines a property of type number
or integer
, the
precision must be defined by the format as follows to prevent clients
from guessing the precision incorrectly, and thereby changing the value
unintentionally:
type | format | specified value range |
---|---|---|
integer |
int32 |
integer between -231 and 231-1 |
integer |
int64 |
integer between -263 and 263-1 |
integer |
bigint |
arbitrarily large signed integer number |
number |
float |
{IEEE-754-2008}[IEEE 754-2008/ISO 60559:2011] binary32 decimal number |
number |
double |
{IEEE-754-2008}[IEEE 754-2008/ISO 60559:2011] binary64 decimal number |
number |
decimal |
arbitrarily precise signed decimal number |
The precision must be translated by clients and servers into the most
specific language types. E.g. for the following definitions the most
specific language types in Java will translate to BigDecimal
for
Money.amount
and int
or Integer
for the OrderList.page_size
:
components:
schemas:
Money:
type: object
properties:
amount:
type: number
description: Amount expressed as a decimal number of major currency units
format: decimal
example: 99.95
...
OrderList:
type: object
properties:
page_size:
type: integer
description: Number of orders in list
format: int32
example: 42