Skip to main content

Authentication

The finperks Giftcard API requires requests to be signed for authentication. finperks provides a key id and key secret as credentials. These credentials are scoped to the specific API environment and may be scoped further to only supporting specific actions to allow safe usage in accordance to the associated risk for the use case. The secret will never have to be included in plain text in a request, but is only used to create the signature.

The API uses this signature algorithm in addition to transport encryption via HTTPS. More information about HTTPS certificate verification can be found under Accessing the API.

Request Signature​

Authorization header format for API requests

Authorization: FP1-HMAC-SHA256 KeyId=ID, Signature=SIGNATURE

For requests, the API expects a standard HTTP Authorization header with a custom authentication scheme, FP1-HMAC-SHA256.

Replace ID with your client id and SIGNATURE with a signature based on certain parts of the request. The specific calculation method to build the signature is described below.

Example Date header

Date: Wed, 09 Jul 2025 16:17:31 GMT

The signature includes the current time, which must be included in the request's Date header.

When the Authorization header is missing or invalid, the API returns HTTP status 401 with a WWW-Authenticate: FP1-HMAC-SHA256 header and an error.

IP Restrictions​

Each API key can be restricted to the IP addresses your requests come from. You configure the allowed IP addresses per API key in the Control Center, when creating or editing the key.

  • Enter one IPv4 or IPv6 address or CIDR range per line, e.g. 203.0.113.10 or 203.0.113.0/24.
  • A single IP address is treated as /32 (IPv4) or /128 (IPv6).
  • If no entries are configured, the key accepts requests from any IP address.

The IP address that counts is the public address your requests reach the API from. If your systems send requests through a NAT gateway or an outbound proxy, configure the address of that gateway or proxy.

Webhook Signature​

For webhooks, we provide the signature in a custom header, Fp-Signature.

Fp-Signature header format for webhook requests

Fp-Signature: FP1-HMAC-SHA256 KeyId=ID, Signature=SIGNATURE

ID will be replaced by the key that was used for the Signature to optimize validation during key rotation.

SIGNATURE will be replaced with a signature based on certain parts of the request. The algorithm for calculating the signature is described below. Webhook requests contain a Date header as used in Request Signature.

When receiving webhooks, always verify the signature.

Calculating the Signature​

Calculating the signature means generating a string with certain parameters and then using your key secret to sign the string with HMAC-SHA256. This section describes how the signature can be calculated. It also contains a signature generator which you can use to confirm the correctness of your implementation.

The string to sign contains the parameters in the following order, separated by newlines (line feed characters \n only).

Example String to sign

api.finperks.com:443
POST
/v1/orders

Wed, 09 Jul 2025 16:17:31 GMT
123e4567-e89b-12d3-a456-426614174000
5906b0dc8f58b526138018e5b1cfef1a9b59e1eb4bfad6850790f8fec1a1e5f0
  • Host and port, separated by a colon, e.g. api.finperks.com:443. The host must match the host in the request's Host-header.
  • HTTP Method, e.g. POST
  • Path, e.g. /v1/orders
  • Query string without question mark
  • Date as specified in the Date header, e.g. Wed, 09 Jul 2025 16:17:31 GMT (make sure the date and your system's clock is correct, it must be within a small window around the current time, otherwise the request is rejected with invalid_date_header)
  • Idempotency key as specified in the Idempotency-Key header (see below, may be empty if the header is not used for a request)
  • SHA-256 digest of the request body (SHA-256 of an empty string if the body is empty), e.g. 5906b0dc8f58b526138018e5b1cfef1a9b59e1eb4bfad6850790f8fec1a1e5f0

The newlines are always necessary, regardless of whether a value is empty or not, so that number of lines in the string to sign is always the same. Do not add a newline after the body digest. Make sure to only use line feed characters, and no carriage returns. This is important, as we use the same mechanism to calculate the signature to verify your credentials.

The last step is signing the string with your key secret. Use the key secret in the form finperks provides it (do not convert the data to binary).

Example Key: 924f85f0-3581-4678-967a-5eb5615a0a41

Example Body (no whitespace or trailing newline):

{"product_code":"b713c564-9e18-4810-a9bb-7b2d86afc8cd","customer":{"id":"test-customer-1"},"country":"DE","face_value":{"currency":"EUR","amount":"10.0"},"processing_mode":"sync","delivery_method":{"type":"code"}}

Bash Example showing body digest and HMAC-SHA256 signing

api_key='924f85f0-3581-4678-967a-5eb5615a0a41'
body='{"product_code":"b713c564-9e18-4810-a9bb-7b2d86afc8cd","customer":{"id":"test-customer-1"},"country":"DE","face_value":{"currency":"EUR","amount":"10.0"},"processing_mode":"sync","delivery_method":{"type":"code"}}'

body_digest=$(printf "%s" "$body" | openssl dgst -sha256 | sed 's/^.* //')
string_to_sign=$(printf "%s\n%s\n%s\n%s\n%s\n%s\n%s" \
'api.finperks.com:443' 'POST' '/v1/orders' '' \
'Wed, 09 Jul 2025 16:17:31 GMT' '123e4567-e89b-12d3-a456-426614174000' "$body_digest")

signature=$(printf "%s" "$string_to_sign" | openssl dgst -sha256 -hmac "$api_key" | sed 's/^.* //')
echo "$signature"

Use the key secret to sign the string using HMAC with SHA-256 as hash function and encode the resulting bytes in hexidecimal form.

With the example string to sign and example key above, you can calculate the following signature:

Example Signature: b398e02643f8be875f059c9ed1fe70b8a30f8bb208db022238b342fbc5a8d554

Code Examples​

Below are complete examples for generating signatures in various languages. Each example includes:

  • A helper function for formatting the Date header in RFC 7231 format
  • The signature generation function
  • A usage example verified against the test data
Common Pitfall: Date Header Formatting

A frequent cause of signature validation failures is an incorrectly formatted day in the Date header. The day must always be two digits with a leading zero (e.g., 09 not 9).

Many standard library date formatters produce Wed, 9 Jul 2025 instead of Wed, 09 Jul 2025, causing signature mismatches.

import hashlib
import hmac
from datetime import datetime, timezone


def get_http_date() -> str:
"""
Returns the current UTC time in RFC 7231 format.
Python's %d format specifier already includes the leading zero.
"""
now = datetime.now(timezone.utc)
return now.strftime('%a, %d %b %Y %H:%M:%S GMT')


def generate_signature(
key_secret: str,
host_with_port: str,
method: str,
path: str,
query_string: str,
date_header: str,
idempotency_key: str,
body: str
) -> str:
body_digest = hashlib.sha256(body.encode('utf-8')).hexdigest()

string_to_sign = '\n'.join([
host_with_port,
method,
path,
query_string,
date_header,
idempotency_key,
body_digest
])

return hmac.new(
key_secret.encode('utf-8'),
string_to_sign.encode('utf-8'),
hashlib.sha256
).hexdigest()


# Usage example with test data
if __name__ == '__main__':
signature = generate_signature(
key_secret='924f85f0-3581-4678-967a-5eb5615a0a41',
host_with_port='api.finperks.com:443',
method='POST',
path='/v1/orders',
query_string='',
date_header='Wed, 09 Jul 2025 16:17:31 GMT',
idempotency_key='123e4567-e89b-12d3-a456-426614174000',
body='{"product_code":"b713c564-9e18-4810-a9bb-7b2d86afc8cd","customer":{"id":"test-customer-1"},"country":"DE","face_value":{"currency":"EUR","amount":"10.0"},"processing_mode":"sync","delivery_method":{"type":"code"}}'
)

expected = 'b398e02643f8be875f059c9ed1fe70b8a30f8bb208db022238b342fbc5a8d554'
assert signature == expected, f'Signature mismatch: {signature}'
print(f'Signature: {signature}')

# For live requests, use get_http_date() instead of a fixed date:
# date_header = get_http_date()
Test Data for Verification

Use these test cases to verify your implementation produces the expected signatures.

POST Request:

ParameterValue
Secret924f85f0-3581-4678-967a-5eb5615a0a41
Hostapi.finperks.com:443
MethodPOST
Path/v1/orders
Query String(empty)
DateWed, 09 Jul 2025 16:17:31 GMT
Idempotency Key123e4567-e89b-12d3-a456-426614174000
Body{"product_code":"b713c564-9e18-4810-a9bb-7b2d86afc8cd","customer":{"id":"test-customer-1"},"country":"DE","face_value":{"currency":"EUR","amount":"10.0"},"processing_mode":"sync","delivery_method":{"type":"code"}}
Body Digest5906b0dc8f58b526138018e5b1cfef1a9b59e1eb4bfad6850790f8fec1a1e5f0
Expected Signatureb398e02643f8be875f059c9ed1fe70b8a30f8bb208db022238b342fbc5a8d554

GET Request:

ParameterValue
Secret924f85f0-3581-4678-967a-5eb5615a0a41
Hostapi.finperks.com:443
MethodGET
Path/v1/products
Query Stringcountrycode=DE
DateWed, 09 Jul 2025 16:17:31 GMT
Idempotency Key(empty)
Body(empty)
Body Digeste3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
Expected Signature248a13a28a88222e8390474059a3640c7148cca9fbcdcc26d3bc3d2b71cfef2a

Example​

Example Request Headers with signature in the Authorization header

POST /v1/orders HTTP/1.1
Authorization: FP1-HMAC-SHA256 KeyId=6b0dff1a-f729-42d1-9eed-d2f17ef5aedb, Signature=b398e02643f8be875f059c9ed1fe70b8a30f8bb208db022238b342fbc5a8d554
Date: Wed, 09 Jul 2025 16:17:31 GMT
Host: api.finperks.com
Idempotency-Key: 123e4567-e89b-12d3-a456-426614174000
Content-Type: application/json

{"product_code":"b713c564-9e18-4810-a9bb-7b2d86afc8cd","customer":{"id":"test-customer-1"},"country":"DE","face_value":{"currency":"EUR","amount":"10.0"},"processing_mode":"sync","delivery_method":{"type":"code"}}

Signature Generator​

This signature generator allows you to verify and debug your implementation of the signature algorithm.

Note:

  • Make sure to not have extra whitespace in any of the fields.
  • Make sure you do not accidentally change the newline characters when copying code between the browser and your text editor. E.g. Windows often adds carriage return characters in addition to line feed characters.

The bytes put into the signature must be the same sent with the actual request, so different kinds of newlines and whitespace can invalidate the signature.