Authenticate your API calls before making API calls. The Invoice API uses JSON web tokens (JWT) for authentication. To generate a token for accessing the API, you need to make use of your generated API KEY. All API calls requires a token for authentication.

Your token is the value of "token" in the json response. This must be included as an Authorization header in all subsequent requests.

POST https://api.invoice.ng/v1/authenticate

Sample Request POST
$request = [
    'headers' => ['Content-Type: application/json'],    
    'url' => 'https://api.invoice.ng/v1/authenticate',
    'params' => json_encode([
        'api_key'     => '5bf9f7943aa18e38c70aedb4a721057c'
    ])
];
                                        
Query Parameters
Parameter Type Description
api_key string The API Key generated from your Invoice account (required)
Response HTTP/1.1 200 OK
{
    "status": "ok",
    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjYzLCJpc3MiOiJodHRwczpcL1wvYXBpLmludm9....",
    "type": "bearer",
    "expiry": 1497881784
}
                                        
Authorization Header
Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjEsImlzcyI6Imh0dHBzOlwvXC9....

An access token will expire in the time defined by expiry in the response from Authentication. If a token has expired you will need to refresh it using the current refresh_token to generate a new access token.

Once this is done the previous access token is invalidated.

Http Request

GET https://api.invoice.ng/v1/token/refresh

Sample Request GET
$request = [
    'headers' => ['Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJ....', 'Content-Type: application/json'],    
    'url' => 'https://api.invoice.ng/token/refresh'
];
                                        
Response HTTP/1.1 200 OK
{
    "status": "ok",
    "refresh_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjYzLCJpc3MiOiJodHRwczpcL1wvYXBpLmludm9...",
    "type": "bearer",
    "expiry": 1497881784
}
                                        

© 2024 InvoiceApp Inc. All Rights Reserved.