4WS Suite
Home
API Reference
  • Data mangement API
  • Documents API
Home
API Reference
  • Data mangement API
  • Documents API
Fourwayshop
  1. Giftcard
  • Document Manager
    • Orders
      • Save Sale Order
      • Save Return Order
    • Orchestrated Orders
      • Orchestrated Order
      • Orchestrated Return order
      • Orchestrated Update order
    • Cart
      • Cart Validation
      • Cart Full Validation
    • Sales
      • Save receipt
      • Salve only Order
      • Replace or update sale
      • Get last digital order
    • Warehouse
      • Save Entry from supplier
      • Save Transfer document
      • Save Free Entry
    • Purchase
      • Save Purchase
    • Get Document
      GET
    • Update Document external references
      POST
  • Customer
    • Get Customer
      GET
    • Set Customer Opt-in
      POST
  • Loyalty vouchers
    • Get customer loyalty vouchers
      GET
    • Get loyalty vouchers at a time interval
      GET
    • Get last loyalty vouchers
      GET
  • Giftcard
    • Get Giftcard
      GET
    • Update Giftcard
      POST
    • Generate Gift Card Barcode
      POST
    • Gift Card PDF Generation
      POST
  • Stock
    • Get Stock
      POST
    • Get last stock
      GET
    • Insert Stock
      POST
  1. Giftcard

Generate Gift Card Barcode

POST
/api
Last modified:2025-11-10 15:54:52

Generate Gift Card Barcode#

This service allows external systems to generate unique barcodes for gift cards that will later be activated during sale.
The service does not sell or activate gift cards—it only generates barcodes with validity dates and returns them asynchronously via callback webhook.
Typical usage:
Create barcode batches for printing on physical gift cards
Generate digital gift card identifiers before selling them through e-commerce
Store generated barcodes in an external system until activation

Actors#

API Client: The system or user initiating the request.
4ws.trade: The backend system that processes the request.
Callback Endpoint (Webhook): The remote URL that receives the asynchronous notification (callback) confirming the creation result of the return order and document.

Preconditions#

The external system must have the necessary permissions and access to the document creation service, please refer to Authentication.
Callback Endpoint (External Client): The callback used by Four Way Shop to asynchronously notify the client of success/failure and to return the order ID must be handled (How Testing callback response).
Monitoring / Alerting System: Handling integration errors and retries logs and warnings, as reported in Best Practices for Error Handling in External System.

Main Success Scenario#

1.
External system sends request with itemCode, quantity, and callback URL
2.
Four Way Shop accepts the request and queues barcode generation
3.
Gift card barcodes are generated with validity dates
4.
Four Way Shop sends results asynchronously to the provided callback URL
5.
External system stores barcodes for future sale/activation

Alternate Flows#

Authentication Error: If the client does not provide valid credentials, an error response is returned.
Error Example
Invalid gift card item code: ItemCode parameter in the request is not a valid item code financial product
Rate Limiting: If the API rate limits are exceeded, the client must respect the retry interval indicated in the response headers Rate Limits.

JSON Structure for Callback Response#

{
  "success": true,
  "giftcards": [
    {
      "barcode": "4443334961511",
      "startValidity": "2022-06-10 00:00:00",
      "endValidity": "2023-06-10 00:00:00"
    }
  ]
}
FieldDescription
barcodeUnique gift card identifier
startValidityActivation window start
endValidityExpiration date

Sequence Diagram#

Best Practices
Please refer to Best Practices for Error Handling in External System for best practices on implementation.
#### Code Example – Node.js
Calling the API#
Receiving the Callback (Express.js example)#

Request

Query Params

Header Params

Body Params application/json

Example
{
    "itemCode" : "GIFTCARD_IVA_TAGLIO_100",
    "giftcards" : 5,
    "callback" : "https://webhook.site/9b012812-2164-43ea-ba24-7c518acd510d"
}

Request Code Samples

Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
Request Request Example
Shell
JavaScript
Java
Swift
curl --location -g --request POST '/api?cmd=generateGiftcards_v1&applicationId={{APPLICATION_ID}}&appId={{APPLICATION_ID}}' \
--header 'applicationId: {{APPLICATION_ID}}' \
--header 'appId: {{APPLICATION_ID}}' \
--header 'namespace: {{NAMESPACE}}' \
--header 'languageId: {{LANGUAGE}}' \
--header 'username: {{USERNAME}}' \
--header 'password: {{PASSWORD}}' \
--header 'companyId: {{COMPANY_ID}}' \
--header 'siteId: {{SITE_ID}}' \
--header 'loadRoles: Y' \
--header 'Content-Type: application/json' \
--data-raw '{
    "itemCode" : "GIFTCARD_IVA_TAGLIO_100",
    "giftcards" : 5,
    "callback" : "https://webhook.site/9b012812-2164-43ea-ba24-7c518acd510d"
}'

Responses

🟢200Generate Giftcards - success enqueue
application/json
Body

Example
{
    "success": true,
    "queueId": "500540dd-75e8-4e56-8a52-d6cb2403b204"
}
🟠422Unique constraint error
Modified at 2025-11-10 15:54:52
Previous
Update Giftcard
Next
Gift Card PDF Generation
Built with