HomeGuidesAPI ReferenceChangelogDiscussions
HomeLog In
Guides

Create Gifts

Function

To create new gift with Open API
透過Open API 建立新贈品

URL

POST <<api_domain>>/v1/gifts

Request Parameters

FieldTypeDescriptionExample
title_translationsHashGift Title
贈品名稱
{ "en": "create by open api"}
media_idsArrayArray of Media ID
一組圖片ID
["603f06f7f6ba0c00451d0f12"]
unlimited_quantityBooleanGift unlimited quantity or not
贈品是否無限數量
true
skuString贈品SKUSKU-456344881
costHashGift Cost
贈品成本
{ "dollars": 12}
weightFloatGift Weight
贈品重量
12.1
quantityFloatGift Quantity
贈品數量
200
product_idStringShared Product ID
共用商品
-
Note:
選擇現有商品新增為贈品 (會共用庫存)
Assign existing product to sell as gift item (the inventory will be shared with selected product)
603f06f7f6ba0c00451d0f12

JSON Response Sample

{
    "_id": "60d5b2b0ca4c5b00176ba405",
    "cost": {
        "cents": 12,
        "currency_symbol": "NT$",
        "currency_iso": "TWD",
        "label": "NT$12",
        "dollars": 12.0
    },
    "title_translations": {
        "en": "create by open api"
    },
    "description_translations": {},
    "media_ids": [
        "603f06f7f6ba0c00451d0f12"
    ],
    "owner_id": "5d8aecb7f21e4e00014d5ae7",
    "sku": "GIFT-SKU-0001",
    "status": "active",
    "unlimited_quantity": true,
    "weight": 12.1,
    "created_at": "2021-06-25T10:40:48.970Z",
    "updated_at": "2021-06-25T10:40:48.970Z",
    "stock_ids": null,
    "root_product_id": null,
    "media": [],
    "quantity": 0
}

Sample CURL Example

curl --location --request POST '<<api_domain>>/v1/gifts' \
--header 'Authorization: Bearer ${token}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "title_translations": { "en": "Sample Gift 0001"},
    "media_ids": ["603f06f7f6ba0c00451d0f12"],
    "unlimited_quantity": true,
    "sku": "GIFT-SKU-0001",
    "cost": { "dollars": 12},
    "weight": 12.1
}'