Skip to main content
Version: 1.28 (Current)

New Object as JSON

Audience: Low-code Engineers

Skill Prerequisites: Actions, Tokens, APIs, JSON

Returns a JSON object as the response of an API endpoint. You list the properties as name/value pairs, and the values can contain tokens.

This action is only available in APIs. It's a final action: it ends the API method, and no actions after it run.

Typical Use Cases​

  • Return a simple result, for example {"success":"true","id":"1001"} after saving a record
  • Return an error object with a matching status code, for example 400 with a message property
  • Return values from tokens, such as API inputs, query results or the current user

Don't use it to​

Action NameDescription
Raw ResponseReturns any content, for example JSON built with Create JSON Object.
Create JSON ObjectBuilds JSON with types and nesting, and saves it in a token.
Existing Object as JSONReturns one list entry as a JSON object.
Existing List as JSONReturns a list as a JSON array.
File ResponseReturns a file.
Download FileSends a file to download.

Input Parameter Reference​

ParameterDescriptionSupports TokensDefaultRequired
Http codeThe HTTP status code of the response, for example 200, 201 or 400 Bad Request. You can add a description after the number, separated by a space. If it's empty, the status is 200.Yesempty stringNo
PropertiesThe properties of the JSON object. Each row has a Name, for example id, and a Value, for example [OrderId]. See Response.YesemptyNo
HTTP HeadersExtra response headers. Each row has a Name, for example Location, and a Value, for example /api/orders/[OrderId]. Content-Type is application/json unless you set it here.YesemptyNo
Allow JSONPWhen the request has a callback query string parameter, wraps the JSON in a call to that function, for example myFunction({...}), and sets Content-Type to application/javascript. Without callback, the JSON is returned as usual.NofalseNo

Response​

The response is one flat JSON object, with the properties in the order of the rows.

{"success":"true","id":"1001","message":"Order SO-1001 was created."}
  • Every value is a JSON string. true, 1001 or a token that holds a number are written as "true" and "1001".
  • Values are escaped. Quotes and special characters are escaped, so the response is always valid JSON. A token that holds JSON, for example [OrderJson], is written as one escaped string, not as a nested object. To nest JSON, use Create JSON Object and Raw Response.
  • Names aren't case-sensitive. id and Id are the same property. If two rows have the same name, only one property is written, with the name of the first row and the value of the last.
  • Rows with an empty Name are skipped. With no rows, the response is {}.

Considerations​

  • APIs only. The action is only available in API methods. In other modules, use Create JSON Object to build JSON in a token.
  • It ends the method. No actions after it run. Put it last, or give it a condition to return different responses, for example a 400 response when an input is missing. See Common Parameters.
  • Http code format. It must start with a number, for example 201 or 201 Created. Other values make the API return an error.
  • Conditions. In a condition, token values are substituted in quotes, so write [email] == "", not "[email]" == "".

Examples​

tip

To understand how to use the below examples, please see Running Examples.

1. Return the ID of a new order​

This action returns 201 Created with the ID of the order saved by an earlier action. The Location header points to the new order.

{
"Title": "New Object as JSON",
"ActionType": "JsonObject",
"Description": "Return the new order ID",
"Parameters": {
"HttpCode": "201 Created",
"Fields": [
{
"name": "success",
"value": "true"
},
{
"name": "id",
"value": "[OrderId]"
}
],
"Headers": [
{
"name": "Location",
"value": "/api/orders/[OrderId]"
}
],
"AllowJsonp": false
}
}

2. Return an error when an input is missing​

This action returns 400 with an error message when the email input of the API method is empty. Put it before the actions that use email.

{
"Title": "New Object as JSON",
"ActionType": "JsonObject",
"Description": "Reject requests without an email",
"Condition": "[email] == \"\"",
"Parameters": {
"HttpCode": "400 Bad Request",
"Fields": [
{
"name": "success",
"value": "false"
},
{
"name": "message",
"value": "The email parameter is required."
}
],
"Headers": [],
"AllowJsonp": false
}
}

Revised 09/27/2026