← Back to Sample APIs

Addition — With Custom Header Auth

Adds two integers, but requires both an api_key and an api_secret sent as custom HTTP request headers. This is a pattern used by many production APIs (e.g. survey API in this lab).

Concept: Custom Header Authentication · api_key + api_secret
Addition API Series — same operation, different style
01

Endpoint

GET https://labs.lowcademy.com/apis/add-custom?input1=5&input2=3
PropertyValue
MethodGET
Fileadd-custom.php
AuthenticationCustom headers: api_key + api_secret
Input styleURL query parameters
02

Authentication — Custom Header Auth

Both headers must be present and match exactly. The server checks them before processing the request.

Lab Credentials — For Training Use Only

Header: api_keylc-api-key-2024
Header: api_secretlc@Secret#2024
03

Query Parameters

ParameterTypeRequiredDescription
input1IntegerRequiredFirst integer to add
input2IntegerRequiredSecond integer to add
04

Sample Requests

cURL

curl -H "api_key: lc-api-key-2024" \
     -H "api_secret: lc@Secret#2024" \
     https://labs.lowcademy.com/apis/add-custom?input1=5&input2=3

JavaScript (fetch)

const res = await fetch('https://labs.lowcademy.com/apis/add-custom?input1=5&input2=3', {
  headers: {
    'api_key'   : 'lc-api-key-2024',
    'api_secret': 'lc@Secret#2024'
  }
});

OutSystems — Custom Headers

// In Consume REST API → On Before Request handler, add:
// Request.Headers → Add("api_key", "lc-api-key-2024")
// Request.Headers → Add("api_secret", "lc@Secret#2024")
05

Response — 200 OK

{
  "success"    : true,
  "auth_method": "Custom Header Auth (api_key + api_secret)",
  "operation"  : "addition",
  "input1"     : 5,
  "input2"     : 3,
  "result"     : 8
}
06

Error Responses

200
OK — Result returned.
401
Unauthorized — Missing or invalid api_key / api_secret headers.
400
Bad Request — Missing or non-numeric input parameters.
405
Method Not Allowed — Use GET.