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

Gift Card PDF Generation

POST
/api
Last modified:2025-11-10 15:55:40

Gift Card PDF Generation#

This service allows generating a print-ready PDF of one or more gift cards.
The PDF is intended to be attached to an email and sent to the final customer for future use.
The system returns a downloadable URL of the generated PDF.

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.
Client calls the API with gift card details
2.
Service validates payload
3.
PDF is generated including barcodes, value, expiry and recipient details
4.
File is stored in cloud storage
5.
API returns a download URL
6.
Client downloads PDF and sends it to recipient via email

Alternate Flows#

Authentication Error: If the client does not provide valid credentials, an error response is returned.
Error Example
Rate Limiting: If the API rate limits are exceeded, the client must respect the retry interval indicated in the response headers Rate Limits.

Sequence Diagram#

External System        Giftcard API Service         Cloud Storage
      |                        |                        |
      |---Request PDF--------->|                        |
      |                        |--Validate payload----->|
      |                        |--Generate PDF--------->|
      |                        |--Store file----------->|
      |                        |<---Return file URL-----|
      |<--PDF Download URL-----|                        |
      |---Download PDF-------->|<---Serve file---------|
Best Practices
Please refer to Best Practices for Error Handling in External System for best practices on implementation.

Code Example (Node.js)#

Request

Query Params

Header Params

Body Params application/json

Example
{
  "giftcards": [
    {
      "emailFrom": "mario.rossi@ciccio.it",
      "nameFrom": "Mario",
      "surnameFrom": "Rossi",
      "emailTo": "Giovanna.sarti@mailmail.com",
      "nameTo": "Giovanna",
      "surnameTo": "Sarti",
      "language": "IT",
      "barcode": "9009978264194",
      "amount": 20,
      "currency": "EUR",
      "endDate": "2023-09-22"
    },
    {
      "emailFrom": "mario.rossi@ciccio.it",
      "nameFrom": "Mario",
      "surnameFrom": "Rossi",
      "emailTo": "Giovanna.sarti@mailmail.com",
      "nameTo": "Giovanna",
      "surnameTo": "Sarti",
      "language": "IT",
      "barcode": "9009978264195",
      "amount": 50,
      "currency": "USD",
      "endDate": "2023-09-22"
    }
  ]
}

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=printGiftcard_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 '{
  "giftcards": [
    {
      "emailFrom": "mario.rossi@ciccio.it",
      "nameFrom": "Mario",
      "surnameFrom": "Rossi",
      "emailTo": "Giovanna.sarti@mailmail.com",
      "nameTo": "Giovanna",
      "surnameTo": "Sarti",
      "language": "IT",
      "barcode": "9009978264194",
      "amount": 20,
      "currency": "EUR",
      "endDate": "2023-09-22"
    },
    {
      "emailFrom": "mario.rossi@ciccio.it",
      "nameFrom": "Mario",
      "surnameFrom": "Rossi",
      "emailTo": "Giovanna.sarti@mailmail.com",
      "nameTo": "Giovanna",
      "surnameTo": "Sarti",
      "language": "IT",
      "barcode": "9009978264195",
      "amount": 50,
      "currency": "USD",
      "endDate": "2023-09-22"
    }
  ]
}'

Responses

🟢200Print Giftcards - success
application/json
Body

Example
{
    "success": true,
    "pdfUrl": "https://storage.googleapis.com/......"
}
Modified at 2025-11-10 15:55:40
Previous
Generate Gift Card Barcode
Next
Get Stock
Built with