Create an Invoice
curl --request POST \
--url https://api.viarosandbox.com/v1/invoices \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"customer_id": "<string>",
"amount": {},
"currency": "<string>",
"description": "<string>",
"due_date": "<string>",
"auto_advance": true
}
'import requests
url = "https://api.viarosandbox.com/v1/invoices"
payload = {
"customer_id": "<string>",
"amount": {},
"currency": "<string>",
"description": "<string>",
"due_date": "<string>",
"auto_advance": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
customer_id: '<string>',
amount: {},
currency: '<string>',
description: '<string>',
due_date: '<string>',
auto_advance: true
})
};
fetch('https://api.viarosandbox.com/v1/invoices', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.viarosandbox.com/v1/invoices",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'customer_id' => '<string>',
'amount' => [
],
'currency' => '<string>',
'description' => '<string>',
'due_date' => '<string>',
'auto_advance' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.viarosandbox.com/v1/invoices"
payload := strings.NewReader("{\n \"customer_id\": \"<string>\",\n \"amount\": {},\n \"currency\": \"<string>\",\n \"description\": \"<string>\",\n \"due_date\": \"<string>\",\n \"auto_advance\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.viarosandbox.com/v1/invoices")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"customer_id\": \"<string>\",\n \"amount\": {},\n \"currency\": \"<string>\",\n \"description\": \"<string>\",\n \"due_date\": \"<string>\",\n \"auto_advance\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.viarosandbox.com/v1/invoices")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"customer_id\": \"<string>\",\n \"amount\": {},\n \"currency\": \"<string>\",\n \"description\": \"<string>\",\n \"due_date\": \"<string>\",\n \"auto_advance\": true\n}"
response = http.request(request)
puts response.read_bodyInvoices & Billing
Create an Invoice
Create and dispatch an invoice to collect payment from a customer.
POST
/
invoices
Create an Invoice
curl --request POST \
--url https://api.viarosandbox.com/v1/invoices \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"customer_id": "<string>",
"amount": {},
"currency": "<string>",
"description": "<string>",
"due_date": "<string>",
"auto_advance": true
}
'import requests
url = "https://api.viarosandbox.com/v1/invoices"
payload = {
"customer_id": "<string>",
"amount": {},
"currency": "<string>",
"description": "<string>",
"due_date": "<string>",
"auto_advance": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
customer_id: '<string>',
amount: {},
currency: '<string>',
description: '<string>',
due_date: '<string>',
auto_advance: true
})
};
fetch('https://api.viarosandbox.com/v1/invoices', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.viarosandbox.com/v1/invoices",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'customer_id' => '<string>',
'amount' => [
],
'currency' => '<string>',
'description' => '<string>',
'due_date' => '<string>',
'auto_advance' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.viarosandbox.com/v1/invoices"
payload := strings.NewReader("{\n \"customer_id\": \"<string>\",\n \"amount\": {},\n \"currency\": \"<string>\",\n \"description\": \"<string>\",\n \"due_date\": \"<string>\",\n \"auto_advance\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.viarosandbox.com/v1/invoices")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"customer_id\": \"<string>\",\n \"amount\": {},\n \"currency\": \"<string>\",\n \"description\": \"<string>\",\n \"due_date\": \"<string>\",\n \"auto_advance\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.viarosandbox.com/v1/invoices")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"customer_id\": \"<string>\",\n \"amount\": {},\n \"currency\": \"<string>\",\n \"description\": \"<string>\",\n \"due_date\": \"<string>\",\n \"auto_advance\": true\n}"
response = http.request(request)
puts response.read_bodyCreates a new invoice for a customer. Once finalized, an invoice generates a hosted payment URL (
hosted_invoice_url) where the customer can select their preferred payment method.
Request Body
string
required
The ID of the customer who will be billed (
cus_...).integer | string
required
The total amount due on the invoice.
string
required
Three-letter ISO currency code (
XAF, XOF, GHS, KES, USD, EUR).string
An arbitrary description or summary of items included on this invoice.
string
The date on which payment for this invoice is due (ISO 8601 format, e.g.
2026-11-20).boolean
default:"true"
Controls whether Pursar will automatically finalize and send the invoice.
Code Examples
curl -X POST https://api.viarosandbox.com/v1/invoices \
-u sk_test_uLsofsae3tB9Izwgeuy0Mxbh4JIxUPSG: \
-H "Content-Type: application/json" \
-d '{
"customer_id": "cus_9f1a2b3c4d5e",
"amount": 75000,
"currency": "XAF",
"description": "Enterprise consulting retainer - November 2026",
"due_date": "2026-11-20"
}'
import requests
url = "https://api.viarosandbox.com/v1/invoices"
auth = ("sk_test_uLsofsae3tB9Izwgeuy0Mxbh4JIxUPSG", "")
payload = {
"customer_id": "cus_9f1a2b3c4d5e",
"amount": 75000,
"currency": "XAF",
"description": "Enterprise consulting retainer - November 2026",
"due_date": "2026-11-20"
}
response = requests.post(url, auth=auth, json=payload)
print(response.json())
const axios = require('axios');
async function createInvoice() {
const response = await axios.post(
'https://api.viarosandbox.com/v1/invoices',
{
customer_id: 'cus_9f1a2b3c4d5e',
amount: 75000,
currency: 'XAF',
description: 'Enterprise consulting retainer - November 2026',
due_date: '2026-11-20'
},
{
auth: {
username: 'sk_test_uLsofsae3tB9Izwgeuy0Mxbh4JIxUPSG',
password: ''
}
}
);
console.log(response.data);
}
createInvoice();
Response
{
"id": "in_1a2b3c4d5e6f",
"object": "invoice",
"customer": "cus_9f1a2b3c4d5e",
"customer_name": "Jane Doe",
"customer_email": "[email protected]",
"amount_due": 75000,
"amount_paid": 0,
"currency": "XAF",
"status": "open",
"description": "Enterprise consulting retainer - November 2026",
"due_date": "2026-11-20T00:00:00Z",
"hosted_invoice_url": "https://invoice.viarosandbox.com/i/in_1a2b3c4d5e6f",
"invoice_pdf": "https://invoice.viarosandbox.com/pdf/in_1a2b3c4d5e6f.pdf",
"created_at": "2026-11-06T12:00:00Z"
}

