JSON API
Using JSON API
Request Type
You need to choose the type of request that you want to send to the API.
You can choose from GET, POST, PUT, PATCH, or DELETE. Each request type has a different purpose and function.
For example, you can use a GET request to retrieve data from the API, or a POST request to send data to the API.
Enter params
You need to enter the parameters that you want to include in your request. Parameters are pieces of information that you send to the API to specify your query or data.
You can use user attributes or custom attributes as parameters. User attributes are predefined attributes that are automatically collected by WhatsApp, such as language, country code, etc.
Custom attributes are attributes that you create and assign to the customer, such as gender, age, interests, etc.
For example, you can use the user attribute “Country Code” as a parameter to get the weather information for the customer’s location.
Body
You need to choose the format and enter the content of the body of your request. The body is the part of the request that contains the data that you want to send to the API.
You can choose from structured or text formats. Structured formats are formats that have a predefined structure and syntax, such as Multipart form or Form URL Encoded.
Text formats are formats that have a flexible and human-readable structure and syntax, such as JSON, XML, YAML, or PLAIN.
For example, you can use the text format JSON to send a JSON object with the customer’s name and email to the API.
Header
You need to enter the key and value pairs of the header of your request. The header is the part of the request that contains the metadata and information about the request, such as the content type, the authorization, the user agent, etc.
You can enter any key and value pairs that are required or optional for the API.
For example, you can enter the key “Content-Type” and the value “application/json” to indicate that the body of your request is in JSON format.
Query
You need to enter the key and value pairs of the query of your request.
The query is the part of the request that contains the parameters that are appended to the URL of the API. You can enter any key and value pairs that are required or optional for the API.
For example, you can enter the key “q” and the value “pizza” to search for pizza restaurants near the customer’s location.
Test request
You need to click on the play button to test your request and see the response from the API.
The response is the part of the message that contains the data or information that the API returns to you. You can see the status code, the headers, and the body of the response.
You can also see the errors or warnings if any.
For example, you can see the status code “200 OK” and the body of the response with the list of pizza restaurants near the customer’s location.
By-pass API error
You can also switch on or off the option to by-pass the API error. This means that you can choose whether to continue or stop your journey/flow if the API returns an error or fails to respond.
You can switch on or off this option by clicking on the toggle button. You can use this option to handle the errors or failures gracefully and avoid breaking your journey/flow.
For example, you can switch on this option and send a fallback message to the customer if the API returns an error or fails to respond.
Last updated