Zum Inhalt springen

Lösungen

Freelancer & Selbstständige Rechnungen und Belege ohne Shop eBay Verkäufe automatisch abrechnen Shopify Bestellungen direkt aus dem Shop WooCommerce WordPress-Shop anbinden

Authentication

Request

All methods use the same endpoint. The header X-Bw-Method determines which function is executed. Every call is sent as a POST request with the payload in the request body – including read methods such as order.read or order.list.

Endpoint

URL https://www.billware.de/api/v1
Method POST
X-Bw-Method Name of the method, e.g. order.create
X-Bw-Hmac API-Appid, a colon and the calculated HMAC, e.g. appid:hmac
Content-Type application/json

authentication

Every API call is authenticated with a HMAC header based on the payload. Below is an example showing how to generate the header. Also refer to the test.connection method which generates and uses the header.

Code Examples

# Get your API secret from your billware customer area
API_SECRET="your-api-secret"

# Sign the exact body that will be sent – not a re-encoded copy of it
PAYLOAD='{"foo":"bar"}'

HMAC=$(printf '%s' "$PAYLOAD" | openssl dgst -sha256 -hmac "$API_SECRET" -binary | base64)

# X-Bw-Hmac is the API-Appid, a colon and the HMAC
echo "your-app-id:$HMAC"

test.connection

You can test your connection. Call the method test.connection with your calculated X-Bw-Hmac header.

Code Examples

# Get your API credentials from your billware customer area
API_APPID="your-app-id"
API_SECRET="your-api-secret"

PAYLOAD='[]'

# The HMAC is calculated over the exact request body that is sent
HMAC=$(printf '%s' "$PAYLOAD" | openssl dgst -sha256 -hmac "$API_SECRET" -binary | base64)

curl -X POST "https://www.billware.de/api/v1" \
  -H "X-Bw-Hmac: $API_APPID:$HMAC" \
  -H "X-Bw-Method: test.connection" \
  -H "Content-Type: application/json" \
  -d "$PAYLOAD"

Postman Example


// Pre-request Script in Postman

const payload = JSON.stringify({});
const apiAppId = APP_ID; // Replace with your actual API App ID
const apiSecret = API_SECRET; // Replace with your actual API Secret

const encoder = new TextEncoder();
const keyData = encoder.encode(apiSecret);
const data = encoder.encode(payload);

crypto.subtle.importKey(
    'raw',
    keyData,
    { name: 'HMAC', hash: 'SHA-256' },
    false,
    ['sign']
).then(key => {
    return crypto.subtle.sign('HMAC', key, data);
}).then(signature => {
    const hmacBase64 = btoa(String.fromCharCode(...new Uint8Array(signature)));

    pm.request.headers.add({
        key: 'X-Bw-Hmac',
        value: `${apiAppId}:${hmacBase64}`
    });

    pm.request.headers.add({
        key: 'X-Bw-Method',
        value: 'test.connection'
    });

    pm.request.headers.add({
        key: 'Content-Type',
        value: 'application/json'
    });
});

Note

In the Body tab, set the type to raw and select JSON as the format. Enter {} as the content.

The data in the Body must be identical to the data used in the Pre-request Script to ensure the HMAC signature is valid.

Response

{
    "response": true,
    "data": null,
    "message": "Connection test success"
}