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"
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 value — objects, arrays, strings, numbers, or booleans:
{
"metadata": {
"tags": ["featured", "sale"],
"dimensions": { "width": 100, "height": 200 }
}
}
Scalar values are also supported:
{ "metadata": "just a string" }
{ "metadata": 42 }
{ "metadata": true }
Types are preserved — numbers stay numbers and booleans stay booleans when read back.
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
| Type | Requires Quotes | Example |
|---|---|---|
string | Yes | "Hello" |
integer | No | 42 |
decimal | No | 29.99 |
boolean | No | true |
date | Yes | "2024-01-15" |
date-time | Yes | "2024-01-15T10:30:00Z" |
guid | Yes | "f38fa478-..." |
object | Object | { "key": "value" } |
| Lookup | Object | { "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:
| Type | Example Default |
|---|---|
string | "pending" |
integer | 42 |
decimal | 19.99 |
boolean | true or false |
date | "2024-01-01" |
guid | "f38fa478-842e-4599-8cbc-918a34b3b789" |
| Lookup | A 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:
| Token | Description | Example |
|---|---|---|
now() | Current UTC date-time | now() |
D | Days | now() + 7D |
H | Hours | now() + 24H |
M | Minutes | now() + 30M |
S | Seconds | now() + 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
| Type | Default Value Field | Supports Expressions |
|---|---|---|
string | stringAttributes.defaultValue | No |
integer | numericAttributes.defaultValue | Yes |
decimal | numericAttributes.defaultValue | Yes |
boolean | defaultValue | Yes |
date | defaultValue | Yes (now()) |
date-time | defaultValue | Yes (now(), now() + 1D) |
guid | defaultValue | Yes (newId()) |
| Lookup | defaultValue | No (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()"
}
]
}
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"
}
}