API - Create Data
In this article, we'll guide you through making an API call to "Create Data" on in Breeze using two methods: curl
and JavaScript's fetch
.
Overview
The Create Data API allows you to send and record data points in your Breeze account. Below you'll find step-by-step instructions for both methods.
This feature is only available on the Advanced plan.
Use Cases
This endpoint can be used for many different applications, including these examples:
Scenario | Action |
---|---|
Transaction in accounting software | Track spend data in Breeze |
Sale of a product | Track sales data in Breeze |
Travel booked through booking software | Measure travel emissions in Breeze |
Adding a line in Google Sheets | Add corresponding data to Breeze |
Form entry in Typeform | Populate Breeze with the response |
Data Definitions
Below is a table defining all the parameters you can use with this API call, their necessity, where to find them, and an example value:
Parameter | Required/Optional | Where to Find | Example Value |
---|---|---|---|
Authorization |
Required | Use this value: 38dd923c599d2db9348ce59955dd4b55 |
Bearer 38dd923c599d2db9348ce59955dd4b55 |
API_key |
Required | Find this value in Settings>Automation | z87rzbuq696cte8ei0bwydyzh3rbo5hanr7 |
organization_ID |
Required | Find this value in Settings>Organization | 1672604772939x326314786611003400 |
place_ID |
Optional | Find this value at the bottom of the Edit Place screen | 1675962175325x419996265711927300 |
source_ID |
Required | Find this value at the bottom of the Edit Source screen | 1672696612518x882123373968097300 |
start_date |
Required | User Input (Format: YYYY/MM/DD) | 2023/01/01 |
end_date |
Optional | User Input (Format: YYYY/MM/DD) | 2023/12/31 |
usage_quantity |
Required | User Input (Format: Number) | 123.321 |
usage_unit |
Required | User Input (E.g., L, ml, kg) See all units here, must be unit symbol | L |
notes |
Optional | User Input (Format: Text) | See invoice |
Using curl
The curl
command is a tool available in most UNIX systems and can be used to make HTTP requests directly from your terminal or application
To use the Create Data API with curl
, follow these steps:
- Open your terminal or command prompt.
- Copy and paste the following command:
bashCopy codecurl --location 'https://mybreeze.io/api/1.1/wf/create-data' \ --header 'Authorization: Bearer YOUR_AUTH_TOKEN' \ --form 'API_key=YOUR_API_KEY' \ --form 'organization_ID=YOUR_ORG_ID' \ --form 'place_ID=YOUR_PLACE_ID' \ --form 'source_ID=YOUR_SOURCE_ID' \ --form 'start_date="YYYY/MM/DD"' \ --form 'end_date="YYYY/MM/DD"' \ --form 'usage_quantity="QUANTITY"' \ --form 'usage_unit="UNIT"' \ --form 'notes="YOUR_NOTES"'
- Replace placeholders
- Press Enter to execute the command. If successful, you will see the response from our server.
Using JavaScript's fetch
For those who prefer or need to use JavaScript, you can utilize the fetch
method.
Follow the steps below:
- Create a new JavaScript file or open your existing project.
- Copy and paste the code snippet below:
javascriptCopy codevar myHeaders = new Headers(); myHeaders.append("Authorization", "Bearer YOUR_AUTH_TOKEN"); var formdata = new FormData(); formdata.append("API_key", "YOUR_API_KEY"); formdata.append("organization_ID", "YOUR_ORG_ID"); formdata.append("place_ID", "YOUR_PLACE_ID"); formdata.append("source_ID", "YOUR_SOURCE_ID"); formdata.append("start_date", "YYYY/MM/DD"); formdata.append("end_date", "YYYY/MM/DD"); formdata.append("usage_quantity", "QUANTITY"); formdata.append("usage_unit", "UNIT"); formdata.append("notes", "YOUR_NOTES"); var requestOptions = { method: 'POST', headers: myHeaders, body: formdata, redirect: 'follow' }; fetch("https://mybreeze.io/api/1.1/wf/create-data", requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error));
- Replace placeholders
- Run your JavaScript file. The results will be displayed in the console.
Troubleshooting
- Authentication Errors: Ensure that the
Authorization
token andAPI_key
are correctly placed. - Data Formatting: Ensure that all data being sent follows the required format. For example, dates should follow the "YYYY/MM/DD" format.
- If you encounter any other issues or have further questions, please contact our support team at support@mybreeze.io
We hope this guide helps you effectively utilize our Create Data API. Happy coding!