The POST method is used to create new objects in the Venddor API. This operation allows you to add products, categories, orders, and other entities to your store.
This endpoint creates a new object of the specified type. The URL should reference the object type without an ID (for example, /api/products
not /api/products/123
).
The request must include a properly formatted JSON object containing the fields and values for the new object. Each object type has different required and optional fields.
Content-Type
must be declared and set to application/json
, otherwise the default text/plain
is assumed and the request will fail.
Header | Value |
---|---|
Content-Type | application/json |
Authorization | Your API authentication credentials |
The request body should be a JSON object containing the fields required for the object type you're creating. For example, when creating a product, you might include fields like name, price, and category.
Creating a new product with the name "My Awesome Product":
curl --user admin@example.com:APIkey --header 'Content-Type: application/json' -d '{"product": "My Awesome Product"}' -X POST 'https://www.venddor.com.br/api/products'
Upon successful creation, the API returns:
{ "product_id": "1" }
The response includes the ID of the newly created object, which you can use to reference it in future API calls.
If the object could not be created, the API will return an appropriate error response with details about what went wrong.
When creating objects using the POST method, consider these best practices: