Create Object (POST)

Overview

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.

POST /api/{object_type}

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).

Request Format

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.

Important: The header Content-Type must be declared and set to application/json, otherwise the default text/plain is assumed and the request will fail.

Required Headers

Header Value
Content-Type application/json
Authorization Your API authentication credentials

Request Body

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.

Tip: Refer to the specific API object documentation pages for a complete list of supported fields for each object type.

Example Request

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'

Response Format

Upon successful creation, the API returns:

Success Response (201 Created)

{
  "product_id": "1"
}

The response includes the ID of the newly created object, which you can use to reference it in future API calls.

Error Response

If the object could not be created, the API will return an appropriate error response with details about what went wrong.

Implementation Notes

When creating objects using the POST method, consider these best practices:

Note: The fields required for object creation vary by object type. Always refer to the specific object documentation for detailed requirements.