Create a Category
POST
Create a Category
https://api.moltin.com/v2/categories
Headers:
Name | Required | Type | Description |
---|---|---|---|
Authorization | Required | string | The Bearer token to grant access to the API. |
Body:
Name | Required | Type | Description |
---|---|---|---|
type | Required | string | Represents the type of the object being returned. |
name | Required | string | The name of the category. |
slug | Required | string | A unique slug identifier for the category. |
description | Optional | string | Any description for this category. |
status | Optional | string | live or draft depending on the category status. (defaults to draft ). |
201 Created
{
"data": {
"id": "9dd56fc2-5746-46a2-bdf6-fe396bb6b7af",
"type": "category",
"status": "live",
"name": "Clothing",
"slug": "clothing",
"description": "Browse our clothing line",
"relationships": {}
}
}
curl -X POST https://api.moltin.com/v2/categories \
-H "Authorization: Bearer XXXX" \
-H "Content-Type: application/json" \
-d $'{
"data": {
"type": "category",
"name": "Clothing",
"slug": "clothing",
"description": "Browse our clothing line",
"status": "live"
}
}'
const MoltinGateway = require('@moltin/sdk').gateway
const Moltin = MoltinGateway({
client_id: 'X',
client_secret: 'X'
})
const category = {
name: 'Clothing',
slug: 'clothing',
description: 'Browse our clothing line',
status: 'live'
}
Moltin.Categories.Create(category).then(category => {
// Do something
})