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 Invoice e-mail address and password. 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.getinvoice.co/v1/authenticate

Request POST
$request = [
    'headers' => ['Content-Type: application/json'],    
    'url' => 'https://api.getinvoice.co/v1/authenticate',
    'params' => json_encode([
        'email'     => 'test@invoice.ng',
        'password'     => 'abx123xyz'
    ])
];
                                        
Query Parameters
Parameter Type Description
email string The registered email address of the user (required)
password string The registered password of the user (required)
Example authentication in HttpClient
$request = [
    'headers' => ['Content-Type: application/json'],    
    'url' => 'https://api.getinvoice.co/v1/authenticate',
    'params' => json_encode([
        'email'     => 'test@invoice.ng',
        'password'     => 'abx123xyz'
    ])
];
                                        
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.getinvoice.co/v1/token/refresh

Response HTTP/1.1 200 OK
{
    "status": "ok",
    "refresh_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjYzLCJpc3MiOiJodHRwczpcL1wvYXBpLmludm9...",
    "type": "bearer",
    "expiry": 1497881784
}
                                        

© 2019 InvoiceApp Inc. All Rights Reserved.