← Back to Sample APIs

Addition — With API Key Header

Adds two integers, authenticated by a single api_key header. This is the most common lightweight auth pattern — one key, no secret.

Concept: Single API Key Header · Lightweight Auth
Addition API Series — same operation, different style
01

Endpoint

GET https://labs.lowcademy.com/apis/add-apikey?input1=5&input2=3
PropertyValue
MethodGET
Fileadd-apikey.php
AuthenticationSingle header: api_key
02

Authentication — API Key Header

Lab Credentials — For Training Use Only

Header: api_keylc-api-key-2024
03

Query Parameters

ParameterTypeRequiredDescription
input1IntegerRequiredFirst integer
input2IntegerRequiredSecond integer
04

Sample Requests

cURL

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

JavaScript (fetch)

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

OutSystems — Custom Header

// On Before Request handler:
// Request.Headers → Add("api_key", "lc-api-key-2024")
05

Response — 200 OK

{
  "success"    : true,
  "auth_method": "API Key Header",
  "operation"  : "addition",
  "input1"     : 5,
  "input2"     : 3,
  "result"     : 8
}
06

Error Responses

200
OK
401
Unauthorized — Missing or invalid api_key header.
400
Bad Request — Missing or non-numeric parameters.
405
Method Not Allowed