---
updatedAt: 2026-05-27T07:01:03.000Z
agentTools:
  projectIndex: https://open-api.docs.shoplineapp.com/llms.txt
---

# Update Customer Store Credits

To update customer store credits with open API<br>使用open API更新顧客購物金

# OpenAPI definition

```json
{
  "info": {
    "title": "SHOPLINE Open API",
    "version": "2.348.2",
    "description": "Welcome to the shopline open-api developer hub. You'll find comprehensive guides and documentation to help you start working with shopline open-api as quickly as possible, as well as support if you get stuck. Let's jump right in!"
  },
  "servers": [
    {
      "url": "https://open.shopline.io/v1",
      "description": "Production"
    }
  ],
  "openapi": "3.0.0",
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    },
    "schemas": {
      "Money": {
        "type": "object",
        "properties": {
          "cents": {
            "type": "integer"
          },
          "currency_symbol": {
            "type": "string"
          },
          "currency_iso": {
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "dollars": {
            "type": "number"
          }
        },
        "example": {
          "cents": 999999999,
          "currency_symbol": "NT$",
          "currency_iso": "TWD",
          "label": "NT$999,999,999",
          "dollars": 999999999
        }
      },
      "StoreCredit": {
        "type": "object",
        "properties": {
          "_id": {
            "description": "Record ID<br>紀錄 ID",
            "type": "string",
            "example": "5f55ad58d9ce6d003c1fd62f"
          },
          "customer_id": {
            "description": "Customer ID<br>顧客 ID",
            "type": "string",
            "example": "5f47c96a86a983001614a834"
          },
          "credit_balance": {
            "description": "Credit balance after this record<br>此紀錄後的購物金餘額",
            "type": "integer",
            "example": 160
          },
          "remarks": {
            "description": "Credit Change Reason\t<br>購物金更動原因",
            "type": "string",
            "example": "hello"
          },
          "value": {
            "description": "Credit Movement<br>購物金款項",
            "type": "integer",
            "example": 20
          },
          "end_at": {
            "description": "Expiry Date, a null value means the credit never expires<br> 到期日, null 表示不會到期",
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "example": "2021-11-30T00:00:00.000+00:00"
          },
          "performer_id": {
            "description": "ID of the staff who created this record<br>創建紀錄的管理員的ID",
            "type": "string",
            "example": "61ad96bda6633e004cafe7db"
          },
          "performer_name": {
            "description": "Staff who created this record<br>創建紀錄的管理員",
            "type": "string",
            "example": "staff1"
          },
          "fulfillment_balance": {
            "description": "Fulfillment Balance<br>購物金餘額",
            "type": "integer",
            "example": 10
          },
          "type": {
            "description": "Store credit type<br>購物金類型 <br>----<br> manual_credit: 手動增減購物金（店家手動發送、回補來自取消訂單/退貨訂單）<br> welcome_credit: 新加入會員購物金<br> birthday_credit: 生日購物金<br> auto_reward: 購物金回饋<br> applied_credit: 套用購物金在訂單<br> user_credit_expired: 購物金過期<br> welcome_member_referral_credit: 透過推薦連結註冊成功<br> member_referral_credit: 推薦新顧客進行消費<br> order_split_revert: 回補購物金（來自拆單）<br> product_review_reward: 商品評價獎賞<br> member_info_quick_completion_credit: 會員資料獎賞<br> return_order_revert: 退貨單回補購物金<br> order_edit_revert: 訂單編輯回補購物金",
            "type": "string",
            "enum": [
              "manual_credit",
              "welcome_credit",
              "birthday_credit",
              "auto_reward",
              "applied_credit",
              "user_credit_expired",
              "welcome_member_referral_credit",
              "member_referral_credit",
              "order_split_revert",
              "member_info_quick_completion_credit",
              "product_review_reward",
              "return_order_revert",
              "order_edit_revert"
            ],
            "example": "manual_credit"
          },
          "created_at": {
            "description": "Record creation date<br>創建紀錄日期",
            "type": "string",
            "example": "2020-09-07T03:47:44.061Z"
          },
          "customer_ref_user_id": {
            "description": "Third party custom customer id<br>第三方儲存之顧客ID",
            "type": "string",
            "example": "MEMBR000000000000019034194"
          },
          "status": {
            "description": "Status<br>購物金狀態",
            "type": "string",
            "enum": [
              "active",
              "removed",
              "expired",
              "used",
              "redeemed"
            ],
            "example": "active"
          },
          "is_redeem": {
            "description": "Whether the store credit is redeemed<br> 購物金是否已經被兌換",
            "type": "boolean",
            "example": false
          },
          "order_id": {
            "description": "The ID of the order where the store credit earned from<br>賺取購物金的訂單的ID",
            "type": "string",
            "example": "621701406dcff70039642cde"
          },
          "value_dollar": {
            "allOf": [
              {
                "$ref": "#/components/schemas/Money"
              },
              {
                "description": "The value of the store credit displayed in dollar<br> 以元表示購物金的價值"
              }
            ]
          },
          "user_credit_rule_id": {
            "description": "The ID of user_credit_rule",
            "type": "string",
            "example": "583d630a69702d70850c0000"
          },
          "order_number": {
            "description": "Order number<br>訂單號碼",
            "type": "string",
            "example": "2019052707260498"
          },
          "merchant_order_number": {
            "description": "The order number set by the merchant<br>店家自定義訂單號",
            "type": "string"
          },
          "order_created_by": {
            "description": "Order created by<br>此訂單的建立者",
            "type": "string"
          }
        }
      },
      "ServerError": {
        "type": "object",
        "properties": {
          "message": {
            "description": "A detailed message of the reason of failure",
            "example": "Unable to create EventTrackers",
            "type": "string"
          },
          "code": {
            "description": "An error code",
            "example": "UnknownError",
            "type": "string"
          }
        }
      },
      "NotFoundError": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string",
            "example": "Unable to find the resource"
          },
          "code": {
            "type": "string",
            "example": "NOT_FOUND"
          },
          "extras": {
            "description": "Optional, Extra information about the error",
            "example": {},
            "type": "object"
          }
        }
      },
      "UnauthorizedError": {
        "type": "object",
        "properties": {
          "message": {
            "description": "A detailed message of the reason of failure",
            "example": "App token not found or invalid",
            "type": "string"
          },
          "code": {
            "description": "An error code",
            "example": "MissingTokenError",
            "type": "string"
          },
          "extras": {
            "description": "Optional, Extra information about the error",
            "example": {},
            "type": "object"
          }
        }
      },
      "UnprocessableEntityError": {
        "type": "object",
        "properties": {
          "error": {
            "description": "A detailed message of the reason of failure",
            "type": "string"
          },
          "message": {
            "description": "A detailed message of the reason of failure",
            "example": "Unable to process the changes [\"event_type\" is not valid], [\"config_data.access_token\" is not valid]",
            "type": "string"
          },
          "code": {
            "description": "An error code",
            "example": "ValidationError",
            "type": "string"
          },
          "extras": {
            "description": "An extra information of the reason of failure",
            "type": "object"
          }
        }
      }
    }
  },
  "paths": {
    "/customers/{id}/store_credits": {
      "post": {
        "summary": "Update Customer Store Credits",
        "description": "To update customer store credits with open API<br>使用open API更新顧客購物金",
        "parameters": [
          {
            "name": "id",
            "description": "Customer ID<br>顧客ID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "example": "58d3440869702d39b7060000"
          },
          {
            "name": "excludes[]",
            "description": "Exclude certain parameters in the response<br>結果要排除哪些參數",
            "in": "query",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string",
                "example": "status"
              }
            }
          },
          {
            "name": "fields[]",
            "description": "Only show certain parameters in the response<br> 結果只顯示哪些參數",
            "in": "query",
            "required": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string",
                "example": "status"
              }
            }
          }
        ],
        "requestBody": {
          "required": true,
          "description": "Store credit adjustment for one customer.",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "value",
                  "remarks"
                ],
                "properties": {
                  "value": {
                    "description": "Credits to be added or deducted<br>增加或減除金額<br>-<br>*Number can be -999999~999999",
                    "type": "integer",
                    "minimum": -999999,
                    "maximum": 999999,
                    "example": 100
                  },
                  "remarks": {
                    "description": "Reason for adding or deducting credits<br>增加或減除購物金原因<br>-<br>* Limit to max 50 characters",
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 49,
                    "example": "add 100 store credits"
                  },
                  "expires_at": {
                    "description": "Validity Period<br>有效期限<br>* Date cannot be in the past <br>* Date should be within 9999 days from now",
                    "type": "string",
                    "format": "date",
                    "example": "2027-11-30"
                  },
                  "email_target": {
                    "description": "Notification with Email<br>是否發送email通知<br>Only applicable for addition<br>僅適用於增加<br>-<br> 1=NOT_SEND全部不送<br> 3=SEND_TO_ALL全部都送",
                    "type": "integer",
                    "enum": [
                      1,
                      3
                    ],
                    "example": 1
                  },
                  "sms_notification_target": {
                    "description": "Notification with SMS<br>是否發送簡訊通知<br>Only applicable for addition<br>僅適用於增加<br>-<br> 1=NOT_SEND全部不送<br> 2=SEND_VERIFIED只送手機驗證過的<br> 3=SEND_TO_ALL全部都送",
                    "type": "integer",
                    "enum": [
                      1,
                      2,
                      3
                    ],
                    "example": 1
                  },
                  "replace": {
                    "description": "To replace all store credits with the current value<br>以此金額替代之前所有購物金",
                    "type": "boolean",
                    "example": true
                  },
                  "type": {
                    "description": "Store credit type<br> 購物金類型<br> * `manual_credit`<br> Manually assign store credit(s) to specific member<br> 手動發送購物金給指定會員<br> * `welcome_credit`<br> Auto assign welcome credits to new registered members<br> 發送購物金鼓勵顧客註冊會員和進行第一次購物<br> * `birthday_credit`<br> Auto assign store credits to members as gifts on their birthday<br> 於會員的生日自動發送購物金作為生日禮物<br> * `auto_reward`<br> Auto reward customers with credits when they meet a minimum amount of purchase<br> 當訂單達到最低金額時自動發送購物金給會員<br> * `applied_credit`<br> Applied user credits when placing an order<br> 在下訂單時已折抵的購物金<br> * `user_credit_expired`<br> Expired user credits<br> 已過期的購物金<br> * `welcome_member_referral_credit`<br> Referral will get store credits after sign up<br> 新會員透過推薦連結註冊成為會員即可獲得購物金<br> * `member_referral_credit`<br> Referrer will get the reward after an order from referral is completed<br> 新顧客註冊後在訂單轉為「已完成」後，推薦人即可獲得購物金<br> * `member_info_quick_completion_credit`<br> Member info reward credit<br> 會員資料獎賞購物金<br> * `order_split_revert`<br> Order split revert credit<br> 訂單拆單回補購物金<br> * `product_review_reward`<br> Product review reward credit<br> 商品評價獎賞購物金<br> * `return_order_revert`<br> Return order revert credit<br> 退貨單回補購物金<br> * `order_edit_revert`<br> Order edit revert credit<br> 訂單編輯回補購物金<br>",
                    "type": "string",
                    "enum": [
                      "manual_credit",
                      "welcome_credit",
                      "birthday_credit",
                      "auto_reward",
                      "applied_credit",
                      "user_credit_expired",
                      "welcome_member_referral_credit",
                      "member_referral_credit",
                      "member_info_quick_completion_credit",
                      "order_split_revert",
                      "product_review_reward",
                      "return_order_revert",
                      "order_edit_revert"
                    ],
                    "default": "manual_credit",
                    "example": "manual_credit"
                  },
                  "performer_id": {
                    "description": "Performer ID<br>操作者ID",
                    "type": "string"
                  },
                  "performer_type": {
                    "description": "Performer Type<br>操作者類型",
                    "type": "string",
                    "enum": [
                      "User",
                      "Agent"
                    ],
                    "default": "User"
                  }
                }
              }
            }
          }
        },
        "tags": [
          "Customers"
        ],
        "responses": {
          "201": {
            "description": "CREATED",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StoreCredit"
                }
              }
            }
          },
          "401": {
            "description": "Bad authentication",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnauthorizedError"
                },
                "examples": {
                  "1": {
                    "summary": "App token not found or invalid",
                    "value": {
                      "error": "App token not found or invalid",
                      "code": "MissingTokenError",
                      "caused_by": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "error": "not allowed to updateStoreCredit? this Customer",
                  "code": "AccessForbiddenError"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                },
                "examples": {
                  "1": {
                    "summary": "Product not found",
                    "value": {
                      "error": "Not found.",
                      "code": "NotFoundError",
                      "caused_by": null
                    }
                  },
                  "2": {
                    "summary": "Customer not found",
                    "value": {
                      "error": "Not found.",
                      "code": "NotFoundError",
                      "caused_by": null
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnprocessableEntityError"
                },
                "examples": {
                  "1": {
                    "summary": "Invalid value",
                    "value": {
                      "error": "value is invalid, value does not have a valid value",
                      "code": "UnprocessableEntityError"
                    }
                  },
                  "2": {
                    "summary": "Invalid expires_at",
                    "value": {
                      "error": "expires_at is invalid",
                      "code": "UnprocessableEntityError"
                    }
                  },
                  "3": {
                    "summary": "Invalid email_target",
                    "value": {
                      "error": "email_target does not have a valid value",
                      "code": "UnprocessableEntityError"
                    }
                  },
                  "4": {
                    "summary": "Invalid sms_notification_target",
                    "value": {
                      "error": "sms_notification_target does not have a valid value",
                      "code": "UnprocessableEntityError"
                    }
                  },
                  "5": {
                    "summary": "Invalid value of replace",
                    "value": {
                      "error": "replace is invalid",
                      "code": "UnprocessableEntityError"
                    }
                  },
                  "7": {
                    "summary": "Invalid order_id",
                    "value": {
                      "error": "OrderId invalid",
                      "code": "UnprocessableEntityError"
                    }
                  },
                  "0008": {
                    "summary": "Invalid type",
                    "value": {
                      "error": "type does not have a valid value",
                      "code": "UnprocessableEntityError"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServerError"
                },
                "examples": {
                  "1": {
                    "summary": "Unknown error",
                    "value": {
                      "message": "Unable to post updateStoreCredit",
                      "code": "UNKNOWN"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "tags": [
    {
      "name": "Customers",
      "description": "Operations about customers"
    }
  ]
}
```