{
  "$meta": {
    "package": "@walkeros/server-destination-api",
    "version": "4.2.1",
    "type": "destination",
    "platform": [
      "server"
    ],
    "docs": "https://www.walkeros.io/docs/destinations/api/server",
    "source": "https://github.com/elbwalker/walkerOS/tree/main/packages/server/destinations/api/src"
  },
  "schemas": {
    "settings": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {
        "url": {
          "type": "string",
          "format": "uri",
          "description": "The API endpoint URL to send events to"
        },
        "headers": {
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {
            "type": "string"
          },
          "description": "Custom HTTP headers to include with requests"
        },
        "method": {
          "type": "string",
          "description": "HTTP method to use (default: POST)"
        },
        "timeout": {
          "type": "number",
          "exclusiveMinimum": 0,
          "description": "Request timeout in milliseconds (default: 5000)"
        }
      },
      "required": [
        "url"
      ],
      "additionalProperties": false
    }
  },
  "examples": {
    "env": {
      "init": {},
      "simulation": [
        "sendServer"
      ],
      "standard": {
        "sendServer": {
          "$code": "()=>Promise.resolve({ok:!0})"
        }
      }
    },
    "step": {
      "customHeaders": {
        "title": "Custom headers",
        "description": "A form submission is sent to the API with custom request headers such as an API key for authentication.",
        "in": {
          "name": "form submit",
          "data": {
            "type": "contact",
            "email": "user@example.com"
          },
          "context": {
            "dev": [
              "test",
              1
            ]
          },
          "globals": {
            "lang": "elb"
          },
          "custom": {
            "completely": "random"
          },
          "user": {
            "id": "us3r",
            "device": "c00k13",
            "session": "s3ss10n"
          },
          "nested": [
            {
              "entity": "child",
              "data": {
                "is": "subordinated"
              }
            }
          ],
          "consent": {
            "functional": true
          },
          "id": "ddaee278ce4ae264",
          "trigger": "test",
          "entity": "form",
          "action": "submit",
          "timestamp": 1700000801,
          "timing": 3.14,
          "source": {
            "count": 1,
            "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
            "type": "express",
            "platform": "server"
          }
        },
        "mapping": {
          "data": "data"
        },
        "out": [
          [
            "sendServer",
            "https://api.example.com/events",
            "{\"type\":\"contact\",\"email\":\"user@example.com\"}",
            {
              "headers": {
                "X-API-Key": "YOUR_API_KEY"
              }
            }
          ]
        ]
      },
      "customTransform": {
        "title": "Custom payload",
        "description": "An order event is reshaped via a data mapping into a custom JSON payload with renamed fields for the API.",
        "in": {
          "name": "order complete",
          "data": {
            "id": "ORD-500",
            "total": 199.99,
            "currency": "USD"
          },
          "context": {
            "shopping": [
              "complete",
              0
            ]
          },
          "globals": {
            "pagegroup": "shop"
          },
          "custom": {
            "completely": "random"
          },
          "user": {
            "id": "buyer-42"
          },
          "nested": [
            {
              "entity": "product",
              "data": {
                "id": "ers",
                "name": "Everyday Ruck Snack",
                "color": "black",
                "size": "l",
                "price": 420
              },
              "context": {
                "shopping": [
                  "complete",
                  0
                ]
              },
              "nested": []
            },
            {
              "entity": "product",
              "data": {
                "id": "cc",
                "name": "Cool Cap",
                "size": "one size",
                "price": 42
              },
              "context": {
                "shopping": [
                  "complete",
                  0
                ]
              },
              "nested": []
            },
            {
              "entity": "gift",
              "data": {
                "name": "Surprise"
              },
              "context": {
                "shopping": [
                  "complete",
                  0
                ]
              },
              "nested": []
            }
          ],
          "consent": {
            "functional": true
          },
          "id": "dae1c5078cafe5b1",
          "trigger": "load",
          "entity": "order",
          "action": "complete",
          "timestamp": 1700000802,
          "timing": 3.14,
          "source": {
            "count": 1,
            "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
            "type": "express",
            "platform": "server"
          }
        },
        "mapping": {
          "data": {
            "map": {
              "order_id": "data.id",
              "amount": "data.total",
              "currency": "data.currency",
              "customer_id": "user.id",
              "event_type": "name"
            }
          }
        },
        "out": [
          [
            "sendServer",
            "https://api.example.com/events",
            "{\"order_id\":\"ORD-500\",\"amount\":199.99,\"currency\":\"USD\",\"customer_id\":\"buyer-42\",\"event_type\":\"order complete\"}",
            {}
          ]
        ]
      },
      "fullEvent": {
        "title": "Forward event data",
        "description": "A page view is POSTed to the configured endpoint with the event data serialized as the JSON body.",
        "in": {
          "name": "page view",
          "data": {
            "title": "Docs",
            "url": "https://example.com/docs"
          },
          "context": {
            "dev": [
              "test",
              1
            ]
          },
          "globals": {
            "pagegroup": "docs"
          },
          "custom": {
            "completely": "random"
          },
          "user": {
            "id": "us3r",
            "device": "c00k13",
            "session": "s3ss10n"
          },
          "nested": [
            {
              "entity": "child",
              "data": {
                "is": "subordinated"
              }
            }
          ],
          "consent": {
            "functional": true
          },
          "id": "9523ab1d5a023220",
          "trigger": "load",
          "entity": "page",
          "action": "view",
          "timestamp": 1700000800,
          "timing": 3.14,
          "source": {
            "count": 1,
            "trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
            "type": "express",
            "platform": "server"
          }
        },
        "mapping": {
          "data": "data"
        },
        "out": [
          [
            "sendServer",
            "https://api.example.com/events",
            "{\"title\":\"Docs\",\"url\":\"https://example.com/docs\"}",
            {}
          ]
        ]
      }
    }
  }
}