Skip to main content

Data Types

RestAPI.com supports several data types for collection properties.

Primitive Types

string

Text values up to 1024 characters.

{ "name": "title", "type": "string" }

JSON format: "Hello World"

integer

Whole numbers from -2,147,483,648 to 2,147,483,647.

{ "name": "quantity", "type": "integer" }

JSON format: 42

decimal

Decimal numbers from -922,337,203,685,477.5808 to 922,337,203,685,477.5807.

{ "name": "price", "type": "decimal" }

JSON format: 29.99 (use period as separator)

boolean

True or false values.

{ "name": "isActive", "type": "boolean" }

JSON format: true or false

date

Date-only values from January 1, 1753 to December 31, 9999.

{ "name": "birthDate", "type": "date" }

JSON format: "2024-01-15"

date-time

Date and time in ISO 8601 format (UTC).

{ "name": "createdAt", "type": "date-time" }

JSON format: "2024-01-15T10:30:00Z"

note

DateTime values are stored in UTC. Values without timezone indicators are treated as UTC.

guid

Globally unique identifier (128-bit UUID).

{ "name": "externalId", "type": "guid" }

JSON format: "f38fa478-842e-4599-8cbc-918a34b3b789"

Format: 8-4-4-4-12 hexadecimal characters separated by hyphens.

Complex Types

blob

Binary large object for file storage.

{ "name": "image", "type": "blob" }

Upload via POST with multipart/form-data. See Working with BLOBs.

object

Arbitrary JSON structure for flexible, schema-less data.

{ "name": "metadata", "type": "object" }

JSON format: Any valid JSON object or array:

{
"metadata": {
"tags": ["featured", "sale"],
"dimensions": { "width": 100, "height": 200 }
}
}
note

Use object when you need flexible structures. For typed relationships between collections, use lookups instead.

Lookups

Reference to an item in another collection. Set typeName to the target collection name.

{ "name": "customer", "typeName": "customers" }

JSON format: { "id": "customer-guid-here" }

When reading data, lookups return the referenced item's display property along with the ID.

JSON Formatting Rules

TypeRequires QuotesExample
stringYes"Hello"
integerNo42
decimalNo29.99
booleanNotrue
dateYes"2024-01-15"
date-timeYes"2024-01-15T10:30:00Z"
guidYes"f38fa478-..."
objectObject{ "key": "value" }
LookupObject{ "id": "..." }

Default Values

Properties can have default values that are automatically applied when creating or replacing items without providing a value. Default values support both static values and dynamic expressions.

Static Default Values

Set a fixed value that applies to all new items:

TypeExample Default
string"pending"
integer42
decimal19.99
booleantrue or false
date"2024-01-01"
guid"f38fa478-842e-4599-8cbc-918a34b3b789"
LookupA specific item ID

Expression-Based Default Values

Use expressions for dynamic values calculated at insert time:

Date and Time Expressions

now()           # Current UTC date-time
now() + 1D # Tomorrow (1 day from now)
now() - 7D # 7 days ago
now() + 2H # 2 hours from now
now() + 30M # 30 minutes from now

Date/time tokens:

TokenDescriptionExample
now()Current UTC date-timenow()
DDaysnow() + 7D
HHoursnow() + 24H
MMinutesnow() + 30M
SSecondsnow() + 60S

Tokens are case-insensitive. All date/time values are stored and evaluated in UTC.

GUID Expressions

newId()         # Generate a unique GUID for each new item

Numeric Expressions

10 + 5          # Evaluates to 15
Floor(18.97) # Evaluates to 18
10.5 + 2.3 # Evaluates to 12.8

Available math functions: Abs, Ceiling, Floor, Round, Max, Min, Pow, Sqrt

Boolean Expressions

true            # Always true
false # Always false
1 > 0 # Evaluates to true
1 == 1 # Evaluates to true

Default Values by Type

TypeDefault Value FieldSupports Expressions
stringstringAttributes.defaultValueNo
integernumericAttributes.defaultValueYes
decimalnumericAttributes.defaultValueYes
booleandefaultValueYes
datedefaultValueYes (now())
date-timedefaultValueYes (now(), now() + 1D)
guiddefaultValueYes (newId())
LookupdefaultValueNo (static ID only)

Schema Example

{
"name": "orders",
"properties": [
{
"name": "status",
"typeName": "string",
"stringAttributes": { "defaultValue": "pending" }
},
{
"name": "quantity",
"typeName": "integer",
"numericAttributes": { "defaultValue": "1" }
},
{
"name": "createdAt",
"typeName": "date-time",
"defaultValue": "now()"
},
{
"name": "dueDate",
"typeName": "date-time",
"defaultValue": "now() + 7D"
},
{
"name": "trackingId",
"typeName": "guid",
"defaultValue": "newId()"
}
]
}
note

Default values are applied during POST and PUT operations when a property is not provided. PATCH operations do not apply default values since they only update specified fields.

Type Validation

Invalid types in requests return 400 Bad Request:

{
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid value for property 'price': expected decimal"
}
}