# Authentication
Source: https://docs.swervpay.co/api-reference/authentication
Authenticate with Swerv API
Swervpay employs OAuth 2.0 as its fundamental security protocol. Access to Swerv endpoints necessitates obtaining an access token, granting entry to restricted endpoints.
To get an access token, you must first authenticate with the Swerv API. This is done by sending a POST request to the `/auth` endpoint with your business ID and secret key encoded in base64 as Basic Authorization in the request header.
Authentication URL: `POST` `https://api.swervpay.co/api/v1/auth`
### Sample Request
```javascript Javascript theme={null}
const response = await fetch(`https://api.swervpay.co/api/v1/auth`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Basic ${Buffer.from(`:`).toString("base64")}`
},
body: JSON.stringify({}),
});
if (response.status !== 200 && response.status !== 201) {
const body = await response.json();
throw new Error(body as any);
}
const token = await response.json();
```
```php PHP theme={null}
';
$secretKey = '';
$auth = base64_encode("{$businessId}:{$secretKey}");
$options = [
'http' => [
'header' => "Content-type: application/json\r\nAuthorization: Basic {$auth}",
'method' => 'POST',
'content' => json_encode([]),
],
];
$context = stream_context_create($options);
$response = file_get_contents('https://api.swervpay.co/api/v1/auth', false, $context);
if ($response === FALSE) {
throw new Exception('Error occurred while making request');
}
$httpCode = http_response_code();
if ($httpCode !== 200 && $httpCode !== 201) {
throw new Exception($response);
}
$token = json_decode($response, true);
?>
```
```go Go theme={null}
package main
import (
"bytes"
"encoding/base64"
"encoding/json"
"errors"
"io/ioutil"
"net/http"
)
func main() {
businessID := ""
secretKey := ""
auth := base64.StdEncoding.EncodeToString([]byte(businessID + ":" + secretKey))
client := &http.Client{}
req, _ := http.NewRequest("POST", "https://api.swervpay.co/api/v1/auth", bytes.NewBuffer([]byte("{}")))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Basic "+auth)
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
if resp.StatusCode != 200 && resp.StatusCode != 201 {
bodyBytes, _ := ioutil.ReadAll(resp.Body)
panic(errors.New(string(bodyBytes)))
}
var token map[string]interface{}
json.NewDecoder(resp.Body).Decode(&token)
}
```
### Sample Response
```json Response theme={null}
{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MDc1OTc0NDMsImlhdCI6MTcwNzU5Mzg0MywiaXNzIjoiU3dlcnZwYXkiLCJpZCI6ImJ1c19tdml1TlNNS2k3NHZUWTh5dmZQNm5RIiwidGtuIjp7InR5cCI6ImJlYXJlciIsImlkIjoiZGY2OTNjY2MtM2YwYy00NDAwLWE0YTQtMmM1YjE4YjBjZTNiIn19.53eKLonZZ8zvC_i2M_P4sQfZlmc7x-bSc8J95TCtIwY",
"token": {
"type": "bearer",
"expires_at": 1707597443075,
"issued_at": 1707593843075
}
}
```
The access token gotten from the auth API expires after 1 hour.
# Authentication
Source: https://docs.swervpay.co/api-reference/authentication/auth
POST /auth
Authentication using business id and secret key
# Bill Categories
Source: https://docs.swervpay.co/api-reference/bills/categories
GET /bills/categories
Get list of bill categories
```bash cURL theme={null}
curl -X GET https://api.swervpay.co/api/v1/bills/categories \
-H "Authorization: Bearer " \
-H "Content-Type: application/json"
```
```javascript Node.js theme={null}
import { SwervpayClient } from '@swervpaydev/sdk';
const config = {
secretKey: "",
businessId: ""
}
const swervpay = new SwervpayClient(config);
await swervpay.bill.categories();
```
```php PHP theme={null}
use Swervpaydev\SDK\Swervpay;
$config = [
'business_id' => '',
'secret_key' => ''
];
$client = new Swervpay($config);
$client->bill()->categories()->toArray();
```
```go Go theme={null}
package main
import (
"context"
"fmt"
"github.com/swerv-ltd/swervpay-go"
"log"
)
func main() {
ctx := context.Background()
client := swervpay.NewSwervpayClient(&swervpay.SwervpayClientOption{
BusinessID: "",
SecretKey: "",
})
resp, err := client.Bill.Categories(ctx)
if err != nil {
log.Fatal("error", err.Error())
return
}
}
```
# Create bill
Source: https://docs.swervpay.co/api-reference/bills/create
POST /bills
Create bill
```bash cURL theme={null}
curl -X GET https://api.swervpay.co/api/v1/bills \
-H "Authorization: Bearer " \
-H "Content-Type: application/json"
-d '{
"customer_id": "",
"amount": "",
"reference": "",
"biller_id": "",
"item_id": "",
"category": "",
}'
```
```javascript Node.js theme={null}
import { SwervpayClient } from '@swervpaydev/sdk';
const config = {
secretKey: "",
businessId: ""
}
const swervpay = new SwervpayClient(config);
await swervpay.bill.create({
"amount": "",
"customer_id": "",
"reference": "",
"biller_id": "",
"item_id": "",
"category": "",
});
```
```php PHP theme={null}
use Swervpaydev\SDK\Swervpay;
$config = [
'business_id' => '',
'secret_key' => ''
];
$client = new Swervpay($config);
$payload = array(
"customer_id" => "",
"amount" => "",
"reference" => "",
"biller_id" => "",
"item_id" => "",
"category" => "",
)
$client->bill()->create($payload)->toArray();
```
```go Go theme={null}
package main
import (
"context"
"fmt"
"github.com/swerv-ltd/swervpay-go"
"log"
)
func main() {
ctx := context.Background()
client := swervpay.NewSwervpayClient(&swervpay.SwervpayClientOption{
BusinessID: "",
SecretKey: "",
})
payload := swervpay.BillCreateRequest{
CustomerID: "",
Amount: "",
Reference: "",
BillerID: "",
ItemID: "",
Category: "",
}
resp, err := client.Bill.Create(ctx, payload)
if err != nil {
log.Fatal("error", err.Error())
return
}
}
```
# Get bill
Source: https://docs.swervpay.co/api-reference/bills/get
GET /bills/{id}
Get bill
```bash cURL theme={null}
curl -X GET https://api.swervpay.co/api/v1/bills/ \
-H "Authorization: Bearer " \
-H "Content-Type: application/json"
```
```javascript Node.js theme={null}
import { SwervpayClient } from '@swervpaydev/sdk';
const config = {
secretKey: "",
businessId: ""
}
const swervpay = new SwervpayClient(config);
await swervpay.bill.get("");
```
```php PHP theme={null}
use Swervpaydev\SDK\Swervpay;
$config = [
'business_id' => '',
'secret_key' => ''
];
$client = new Swervpay($config);
$client->bill()->get("")->toArray();
```
```go Go theme={null}
package main
import (
"context"
"fmt"
"github.com/swerv-ltd/swervpay-go"
"log"
)
func main() {
ctx := context.Background()
client := swervpay.NewSwervpayClient(&swervpay.SwervpayClientOption{
BusinessID: "",
SecretKey: "",
})
resp, err := client.Bill.Get(ctx, "")
if err != nil {
log.Fatal("error", err.Error())
return
}
}
```
# Bill Category Items
Source: https://docs.swervpay.co/api-reference/bills/items
GET /bills/categories/{id}/items/{itemId}
Get list of bill category list items
```bash cURL theme={null}
curl -X GET https://api.swervpay.co/api/v1/bills/categories/{id}/items/{itemId} \
-H "Authorization: Bearer " \
-H "Content-Type: application/json"
```
```javascript Node.js theme={null}
import { SwervpayClient } from '@swervpaydev/sdk';
const config = {
secretKey: "",
businessId: ""
}
const swervpay = new SwervpayClient(config);
await swervpay.bill.items("", "");
```
```php PHP theme={null}
use Swervpaydev\SDK\Swervpay;
$config = [
'business_id' => '',
'secret_key' => ''
];
$client = new Swervpay($config);
$client->bill()->items("", "")->toArray();
```
```go Go theme={null}
package main
import (
"context"
"fmt"
"github.com/swerv-ltd/swervpay-go"
"log"
)
func main() {
ctx := context.Background()
client := swervpay.NewSwervpayClient(&swervpay.SwervpayClientOption{
BusinessID: "",
SecretKey: "",
})
resp, err := client.Bill.Items(ctx, "", "")
if err != nil {
log.Fatal("error", err.Error())
return
}
}
```
# Bill Category List
Source: https://docs.swervpay.co/api-reference/bills/lists
GET /bills/categories/{id}
Get list of bill category list
```bash cURL theme={null}
curl -X GET https://api.swervpay.co/api/v1/bills/categories/{id} \
-H "Authorization: Bearer " \
-H "Content-Type: application/json"
```
```javascript Node.js theme={null}
import { SwervpayClient } from '@swervpaydev/sdk';
const config = {
secretKey: "",
businessId: ""
}
const swervpay = new SwervpayClient(config);
await swervpay.bill.list("");
```
```php PHP theme={null}
use Swervpaydev\SDK\Swervpay;
$config = [
'business_id' => '',
'secret_key' => ''
];
$client = new Swervpay($config);
$client->bill()->list("")->toArray();
```
```go Go theme={null}
package main
import (
"context"
"fmt"
"github.com/swerv-ltd/swervpay-go"
"log"
)
func main() {
ctx := context.Background()
client := swervpay.NewSwervpayClient(&swervpay.SwervpayClientOption{
BusinessID: "",
SecretKey: "",
})
resp, err := client.Bill.List(ctx, "")
if err != nil {
log.Fatal("error", err.Error())
return
}
}
```
# Validate customer
Source: https://docs.swervpay.co/api-reference/bills/validate
POST /bills/validate
Validate bill with customer
```bash cURL theme={null}
curl -X GET https://api.swervpay.co/api/v1/bills/validate \
-H "Authorization: Bearer " \
-H "Content-Type: application/json"
-d '{
"biller_id": "",
"customer_id": "",
"category": ""
}'
```
```javascript Node.js theme={null}
import { SwervpayClient } from '@swervpaydev/sdk';
const config = {
secretKey: "",
businessId: ""
}
const swervpay = new SwervpayClient(config);
await swervpay.bill.validate({
"biller_id": "",
"customer_id": "",
"category": ""
});
```
```php PHP theme={null}
use Swervpaydev\SDK\Swervpay;
$config = [
'business_id' => '',
'secret_key' => ''
];
$client = new Swervpay($config);
$client->bill()->validate(array(
"biller_id" => "",
"customer_id" => "",
"category" => ""
));
```
```go Go theme={null}
package main
import (
"context"
"fmt"
"github.com/swerv-ltd/swervpay-go"
"log"
)
func main() {
ctx := context.Background()
client := swervpay.NewSwervpayClient(&swervpay.SwervpayClientOption{
BusinessID: "",
SecretKey: "",
})
payload := swervpay.BillValidateRequest{
BillerID: "",
CustomerID: "",
Category: "",
}
resp, err := client.Bill.Validate(ctx, payload)
if err != nil {
log.Fatal("error", err.Error())
return
}
}
```
# Get Business
Source: https://docs.swervpay.co/api-reference/business/get
GET /business
Get business
```bash cURL theme={null}
curl -X GET https://api.swervpay.co/api/v1/business \
-H "Authorization: Bearer " \
-H "Content-Type: application/json"
```
```javascript Node.js theme={null}
import { SwervpayClient } from '@swervpaydev/sdk';
const config = {
secretKey: "",
businessId: ""
}
const swervpay = new SwervpayClient(config);
await swervpay.business.get();
```
```php PHP theme={null}
use Swervpaydev\SDK\Swervpay;
$config = [
'business_id' => '',
'secret_key' => ''
];
$client = new Swervpay($config);
$client->business()->get();
```
```go Go theme={null}
package main
import (
"context"
"fmt"
"github.com/swerv-ltd/swervpay-go"
"log"
)
func main() {
ctx := context.Background()
client := swervpay.NewSwervpayClient(&swervpay.SwervpayClientOption{
BusinessID: "",
SecretKey: "",
})
resp, err := client.Business.Get(ctx)
if err != nil {
log.Fatal("error", err.Error())
return
}
}
```
# Create Card
Source: https://docs.swervpay.co/api-reference/cards/create
POST /cards
Create card
```bash cURL theme={null}
curl -X POST https://api.swervpay.co/api/v1/cards \
-H "Authorization: Bearer " \
-H "Content-Type: application/json" \
-d '{
"customer_id": "user",
"currency": "USD",
"provider": "MASTERCARD",
"amount": 10,
"type": "DEFAULT"
}'
```
```javascript Node.js theme={null}
import { SwervpayClient } from '@swervpaydev/sdk';
const config = {
secretKey: "",
businessId: ""
}
const swervpay = new SwervpayClient(config);
await swervpay.card.create({
customer_id: "user",
currency: "USD",
provider: "MASTERCARD",
amount: 10,
type: "DEFAULT"
})
```
```php PHP theme={null}
use Swervpaydev\SDK\Swervpay;
$config = [
'business_id' => '',
'secret_key' => ''
];
$client = new Swervpay($config);
$client->card()->create([
"customer_id" => "user",
"currency" => "USD",
"provider" => "MASTERCARD",
"amount" => 10,
"type" => "DEFAULT"
]);
```
```go Go theme={null}
package main
import (
"context"
"fmt"
"github.com/swerv-ltd/swervpay-go"
"log"
)
func main() {
ctx := context.Background()
client := swervpay.NewSwervpayClient(&swervpay.SwervpayClientOption{
BusinessID: "",
SecretKey: "",
})
data := swervpay.CreateCardBody{
Type: "DEFAULT",
Currency: "USD",
Provider: "MASTERCARD",
CustomerId: "user",
Amount: 10
}
resp, err := client.Card.Create(ctx, data)
if err != nil {
log.Fatal("error", err.Error())
return
}
}
```
# Freeze Card
Source: https://docs.swervpay.co/api-reference/cards/freeze
POST /cards/{id}/freeze
Freeze card
```bash cURL theme={null}
curl -X POST https://api.swervpay.co/api/v1/cards/{id}/freeze \
-H "Authorization: Bearer " \
-H "Content-Type: application/json" \
-d '{
}'
```
```javascript Node.js theme={null}
import { SwervpayClient } from '@swervpaydev/sdk';
const config = {
secretKey: "",
businessId: ""
}
const swervpay = new SwervpayClient(config);
await swervpay.card.freeze('')
```
```php PHP theme={null}
use Swervpaydev\SDK\Swervpay;
$config = [
'business_id' => '',
'secret_key' => ''
];
$client = new Swervpay($config);
$client->card()->freeze('');
```
```go Go theme={null}
package main
import (
"context"
"fmt"
"github.com/swerv-ltd/swervpay-go"
"log"
)
func main() {
ctx := context.Background()
client := swervpay.NewSwervpayClient(&swervpay.SwervpayClientOption{
BusinessID: "",
SecretKey: "",
})
resp, err := client.Card.Freeze(ctx, "")
if err != nil {
log.Fatal("error", err.Error())
return
}
}
```
# Fund Card
Source: https://docs.swervpay.co/api-reference/cards/fund-card
POST /cards/{id}/fund
Fund card
```bash cURL theme={null}
curl -X POST https://api.swervpay.co/api/v1/cards/{id}/fund \
-H "Authorization: Bearer " \
-H "Content-Type: application/json" \
-d '{
"amount": 1000
}'
```
```javascript Node.js theme={null}
import { SwervpayClient } from '@swervpaydev/sdk';
const config = {
secretKey: "",
businessId: ""
}
const swervpay = new SwervpayClient(config);
await swervpay.card.fund('', {
amount: "user"
})
```
```php PHP theme={null}
use Swervpaydev\SDK\Swervpay;
$config = [
'business_id' => '',
'secret_key' => ''
];
$client = new Swervpay($config);
$client->card()->fund('', [
"amount" => "user"
]);
```
```go Go theme={null}
package main
import (
"context"
"fmt"
"github.com/swerv-ltd/swervpay-go"
"log"
)
func main() {
ctx := context.Background()
client := swervpay.NewSwervpayClient(&swervpay.SwervpayClientOption{
BusinessID: "",
SecretKey: "",
})
data := swervpay.FundOrWithdrawCardBody{
Amount: 1000
}
resp, err := client.Card.Fund(ctx, "", data)
if err != nil {
log.Fatal("error", err.Error())
return
}
}
```
# Get Card
Source: https://docs.swervpay.co/api-reference/cards/get
GET /cards/{id}
Get card
```bash cURL theme={null}
curl -X GET https://api.swervpay.co/api/v1/cards/{id} \
-H "Authorization: Bearer " \
-H "Content-Type: application/json"
```
```javascript Node.js theme={null}
import { SwervpayClient } from '@swervpaydev/sdk';
const config = {
secretKey: "",
businessId: ""
}
const swervpay = new SwervpayClient(config);
await swervpay.card.get('')
```
```php PHP theme={null}
use Swervpaydev\SDK\Swervpay;
$config = [
'business_id' => '',
'secret_key' => ''
];
$client = new Swervpay($config);
$client->card()->get('');
```
```go Go theme={null}
package main
import (
"context"
"fmt"
"github.com/swerv-ltd/swervpay-go"
"log"
)
func main() {
ctx := context.Background()
client := swervpay.NewSwervpayClient(&swervpay.SwervpayClientOption{
BusinessID: "",
SecretKey: "",
})
resp, err := client.Card.Get(ctx, "")
if err != nil {
log.Fatal("error", err.Error())
return
}
}
```
# Get All Cards
Source: https://docs.swervpay.co/api-reference/cards/get-all-cards
GET /cards
List all cards
```bash cURL theme={null}
curl -X GET https://api.swervpay.co/api/v1/cards \
-H "Authorization: Bearer " \
-H "Content-Type: application/json"
```
```javascript Node.js theme={null}
import { SwervpayClient } from '@swervpaydev/sdk';
const config = {
secretKey: "",
businessId: ""
}
const swervpay = new SwervpayClient(config);
await swervpay.card.gets()
```
```php PHP theme={null}
use Swervpaydev\SDK\Swervpay;
$config = [
'business_id' => '',
'secret_key' => ''
];
$client = new Swervpay($config);
$client->card()->gets()->toArray();
```
```go Go theme={null}
package main
import (
"context"
"fmt"
"github.com/swerv-ltd/swervpay-go"
"log"
)
func main() {
ctx := context.Background()
client := swervpay.NewSwervpayClient(&swervpay.SwervpayClientOption{
BusinessId: businessId
SecretKey: secretKey
})
query := swervpay.PageAndLimitQuery{
Limit: 10,
Page: 1,
}
resp, err := client.Card.Gets(ctx, query)
if err != nil {
log.Fatal("error", err.Error())
return
}
}
```
# Get Card Transaction
Source: https://docs.swervpay.co/api-reference/cards/get-transaction
GET /cards/{id}/transactions/{transactionId}
Get card transactions
```bash cURL theme={null}
curl -X GET https://api.swervpay.co/api/v1/cards/{id}/transactions/{transactionId} \
-H "Authorization: Bearer " \
-H "Content-Type: application/json"
```
```javascript Node.js theme={null}
import { SwervpayClient } from '@swervpaydev/sdk';
const config = {
secretKey: "",
businessId: ""
}
const swervpay = new SwervpayClient(config);
await swervpay.card.transaction('', '');
```
```php PHP theme={null}
use Swervpaydev\SDK\Swervpay;
$config = [
'business_id' => '',
'secret_key' => ''
];
$client = new Swervpay($config);
$client->card()->transaction('', '');
```
```go Go theme={null}
package main
import (
"context"
"fmt"
"github.com/swerv-ltd/swervpay-go"
"log"
)
func main() {
ctx := context.Background()
client := swervpay.NewSwervpayClient(&swervpay.SwervpayClientOption{
BusinessID: "",
SecretKey: "",
})
resp, err := client.Card.Transaction(ctx, "", "")
if err != nil {
log.Fatal("error", err.Error())
return
}
}
```
# Terminate Card
Source: https://docs.swervpay.co/api-reference/cards/terminate
POST /cards/{id}/terminate
Terminate card
```bash cURL theme={null}
curl -X PUT https://api.swervpay.co/api/v1/cards/{id}/terminate \
-H "Authorization: Bearer " \
-H "Content-Type: application/json" \
-d '{
}'
```
```javascript Node.js theme={null}
import { SwervpayClient } from '@swervpaydev/sdk';
const config = {
secretKey: "",
businessId: ""
}
const swervpay = new SwervpayClient(config);
await swervpay.card.terminate('')
```
```php PHP theme={null}
use Swervpaydev\SDK\Swervpay;
$config = [
'business_id' => '',
'secret_key' => ''
];
$client = new Swervpay($config);
$client->card()->terminate('');
```
```go Go theme={null}
package main
import (
"context"
"fmt"
"github.com/swerv-ltd/swervpay-go"
"log"
)
func main() {
ctx := context.Background()
client := swervpay.NewSwervpayClient(&swervpay.SwervpayClientOption{
BusinessID: "",
SecretKey: "",
})
resp, err := client.Card.Terminate(ctx, "")
if err != nil {
log.Fatal("error", err.Error())
return
}
}
```
# Get Card Transactions
Source: https://docs.swervpay.co/api-reference/cards/transactions
GET /cards/{id}/transactions
List all card transactions
```bash cURL theme={null}
curl -X GET https://api.swervpay.co/api/v1/cards/{id}/transactions \
-H "Authorization: Bearer " \
-H "Content-Type: application/json"
```
```javascript Node.js theme={null}
import { SwervpayClient } from '@swervpaydev/sdk';
const config = {
secretKey: "",
businessId: ""
}
const swervpay = new SwervpayClient(config);
await swervpay.card.transactions('')
```
```php PHP theme={null}
use Swervpaydev\SDK\Swervpay;
$config = [
'business_id' => '',
'secret_key' => ''
];
$client = new Swervpay($config);
$client->card()->transactions('');
```
```go Go theme={null}
package main
import (
"context"
"fmt"
"github.com/swerv-ltd/swervpay-go"
"log"
)
func main() {
ctx := context.Background()
client := swervpay.NewSwervpayClient(&swervpay.SwervpayClientOption{
BusinessID: "",
SecretKey: "",
})
resp, err := client.Card.Transactions(ctx, "")
if err != nil {
log.Fatal("error", err.Error())
return
}
}
```
# Unfreeze Card
Source: https://docs.swervpay.co/api-reference/cards/unfreeze
POST /cards/{id}/unfreeze
Unfreeze card
```bash cURL theme={null}
curl -X POST https://api.swervpay.co/api/v1/cards/{id}/unfreeze \
-H "Authorization: Bearer " \
-H "Content-Type: application/json" \
-d '{
}'
```
```javascript Node.js theme={null}
import { SwervpayClient } from '@swervpaydev/sdk';
const config = {
secretKey: "",
businessId: ""
}
const swervpay = new SwervpayClient(config);
await swervpay.card.unfreeze('')
```
```php PHP theme={null}
use Swervpaydev\SDK\Swervpay;
$config = [
'business_id' => '',
'secret_key' => ''
];
$client = new Swervpay($config);
$client->card()->unfreeze('');
```
```go Go theme={null}
package main
import (
"context"
"fmt"
"github.com/swerv-ltd/swervpay-go"
"log"
)
func main() {
ctx := context.Background()
client := swervpay.NewSwervpayClient(&swervpay.SwervpayClientOption{
BusinessID: "",
SecretKey: "",
})
resp, err := client.Card.Unfreeze(ctx, "")
if err != nil {
log.Fatal("error", err.Error())
return
}
}
```
# Withdraw from Card
Source: https://docs.swervpay.co/api-reference/cards/withdraw-from-card
POST /cards/{id}/withdraw
Card withdrawal
```bash cURL theme={null}
curl -X POST https://api.swervpay.co/api/v1/cards/{id}/withdraw \
-H "Authorization: Bearer " \
-H "Content-Type: application/json" \
-d '{
"amount": 1000
}'
```
```javascript Node.js theme={null}
import { SwervpayClient } from '@swervpaydev/sdk';
const config = {
secretKey: "",
businessId: ""
}
const swervpay = new SwervpayClient(config);
await swervpay.card.withdraw('',{
amount: "user"
})
```
```php PHP theme={null}
use Swervpaydev\SDK\Swervpay;
$config = [
'business_id' => '',
'secret_key' => ''
];
$client = new Swervpay($config);
$client->card()->withdraw('', [
"amount" => "user"
]);
```
```go Go theme={null}
package main
import (
"context"
"fmt"
"github.com/swerv-ltd/swervpay-go"
"log"
)
func main() {
ctx := context.Background()
client := swervpay.NewSwervpayClient(&swervpay.SwervpayClientOption{
BusinessID: "",
SecretKey: "",
})
data := swervpay.FundOrWithdrawCardBody{
Amount: 1000,
}
resp, err := client.Card.Withdraw(ctx, "", data)
if err != nil {
log.Fatal("error", err.Error())
return
}
}
```
# Simulate credit transaction
Source: https://docs.swervpay.co/api-reference/checkouts/credit
POST /checkouts/{accountNo}/credit
Simulate credit transaction (Sandbox Only)
# Create Collection
Source: https://docs.swervpay.co/api-reference/collections/create
POST /collections
Create collection
Create a collection account for receiving payments. Collections support existing `NGN` virtual account flows and `USD` collection accounts.
## NGN collection
Use `NGN` collections for Naira virtual accounts. `ONE_TIME` collections require an `amount`. `DEFAULT` permanent collections require a `customer_id`.
```bash theme={null}
curl -X POST https://api.swervpay.co/api/v1/collections \
-H "Authorization: Bearer " \
-H "Content-Type: application/json" \
-d '{
"customer_id": "cus_123456789",
"currency": "NGN",
"merchant_name": "Swervpay",
"amount": 10000,
"type": "ONE_TIME"
}'
```
## USD collection account
Use `USD` collections to issue a permanent USD collection account for an approved customer. USD collections must use `type` set to `DEFAULT` and must include `additional_information`.
```bash theme={null}
curl -X POST https://api.swervpay.co/api/v1/collections \
-H "Authorization: Bearer " \
-H "Content-Type: application/json" \
-d '{
"customer_id": "cus_123456789",
"currency": "USD",
"merchant_name": "Ada Okafor",
"amount": 0,
"type": "DEFAULT",
"additional_information": {
"account_type": "INDIVIDUAL",
"nin": "12345678901",
"tax_number": "12345678901",
"date_of_birth": "1994-04-12",
"employment_status": "EMPLOYED",
"account_designation": "PERSONAL",
"income_band": "UNDER_10000",
"source_of_income": "SALARY",
"address": {
"street": "12 Admiralty Way",
"city": "Lagos",
"state": "Lagos",
"country": "Nigeria",
"zip_code": "100001"
},
"document": {
"type": "NIN",
"number": "12345678901",
"issue_date": "2020-01-01",
"expiry_date": "2030-01-01",
"urls": ["https://example.com/document-front.jpg"]
},
"utility_bill": "https://example.com/utility-bill.pdf",
"bank_statement": "https://example.com/bank-statement.pdf"
}
}'
```
For USD collections, `type` must be `DEFAULT`, `customer_id` is required, and `additional_information` must include the customer's identity, address, source-of-funds, document, utility bill, and bank statement information.
USD account issuance may complete asynchronously. Use the `collection.created` webhook to receive final bank details, or `collection.created.failed` to receive rejection reasons.
# Simulate credit transaction
Source: https://docs.swervpay.co/api-reference/collections/credit
POST /collections/{id}/credit
Simulate credit transaction (Sandbox Only)
# Get Collection
Source: https://docs.swervpay.co/api-reference/collections/get
GET /collections/{id}
Get collection
```bash cURL theme={null}
curl -X GET https://api.swervpay.co/api/v1/collections/{id} \
-H "Authorization: Bearer " \
-H "Content-Type: application/json"
```
```javascript Node.js theme={null}
import { SwervpayClient } from '@swervpaydev/sdk';
const config = {
secretKey: "",
businessId: ""
}
const swervpay = new SwervpayClient(config);
await swervpay.collection.get('')
```
```php PHP theme={null}
use Swervpaydev\SDK\Swervpay;
$config = [
'business_id' => '',
'secret_key' => ''
];
$client = new Swervpay($config);
$client->collection()->get('');
```
```go Go theme={null}
package main
import (
"context"
"fmt"
"github.com/swerv-ltd/swervpay-go"
"log"
)
func main() {
ctx := context.Background()
client := swervpay.NewSwervpayClient(&swervpay.SwervpayClientOption{
BusinessID: "",
SecretKey: "",
})
resp, err := client.Collection.Get(ctx, "")
if err != nil {
log.Fatal("error", err.Error())
return
}
}
```
# Get All Collections
Source: https://docs.swervpay.co/api-reference/collections/get-all-collections
GET /collections
List all collections
```bash cURL theme={null}
curl -X GET https://api.swervpay.co/api/v1/collections \
-H "Authorization: Bearer " \
-H "Content-Type: application/json"
```
```javascript Node.js theme={null}
import { SwervpayClient } from '@swervpaydev/sdk';
const config = {
secretKey: "",
businessId: ""
}
const swervpay = new SwervpayClient(config);
await swervpay.collection.gets()
```
```php PHP theme={null}
use Swervpaydev\SDK\Swervpay;
$config = [
'business_id' => '',
'secret_key' => ''
];
$client = new Swervpay($config);
$client->card()->collection()->toArray();
```
```go Go theme={null}
package main
import (
"context"
"fmt"
"github.com/swerv-ltd/swervpay-go"
"log"
)
func main() {
ctx := context.Background()
client := swervpay.NewSwervpayClient(&swervpay.SwervpayClientOption{
BusinessId: businessId
SecretKey: secretKey
})
query := swervpay.PageAndLimitQuery{
Limit: 10,
Page: 1,
}
resp, err := client.Collection.Gets(ctx, query)
if err != nil {
log.Fatal("error", err.Error())
return
}
}
```
# Get Collection Transactions
Source: https://docs.swervpay.co/api-reference/collections/transaction
GET /collections/{id}/transactions
List all collection transactions
```bash cURL theme={null}
curl -X GET https://api.swervpay.co/api/v1/collections/{id}/transactions \
-H "Authorization: Bearer " \
-H "Content-Type: application/json"
```
```javascript Node.js theme={null}
import { SwervpayClient } from '@swervpaydev/sdk';
const config = {
secretKey: "",
businessId: ""
}
const swervpay = new SwervpayClient(config);
await swervpay.collection.transactions('')
```
```php PHP theme={null}
use Swervpaydev\SDK\Swervpay;
$config = [
'business_id' => '',
'secret_key' => ''
];
$client = new Swervpay($config);
$client->collection()->transactions('');
```
```go Go theme={null}
package main
import (
"context"
"fmt"
"github.com/swerv-ltd/swervpay-go"
"log"
)
func main() {
ctx := context.Background()
client := swervpay.NewSwervpayClient(&swervpay.SwervpayClientOption{
BusinessID: "",
SecretKey: "",
})
resp, err := client.Collection.Transactions(ctx, "")
if err != nil {
log.Fatal("error", err.Error())
return
}
}
```
# Blacklist Customer
Source: https://docs.swervpay.co/api-reference/customers/blacklist
POST /customers/{id}/blacklist
Blacklist customer
```bash cURL theme={null}
curl -X POST https://api.swervpay.co/api/v1/customers/{id}/blacklist \
-H "Authorization: Bearer " \
-H "Content-Type: application/json" \
-d '{
}'
```
```javascript Node.js theme={null}
import { SwervpayClient } from '@swervpaydev/sdk';
const config = {
secretKey: "",
businessId: ""
}
const swervpay = new SwervpayClient(config);
await swervpay.customer.blacklist('');
```
```php PHP theme={null}
use Swervpaydev\SDK\Swervpay;
$config = [
'business_id' => '',
'secret_key' => ''
];
$client = new Swervpay($config);
$client->customer()->blacklist('');
```
```go Go theme={null}
package main
import (
"context"
"fmt"
"github.com/swerv-ltd/swervpay-go"
"log"
)
func main() {
ctx := context.Background()
client := swervpay.NewSwervpayClient(&swervpay.SwervpayClientOption{
BusinessID: "",
SecretKey: "",
})
resp, err := client.Customer.Blacklist(ctx, "")
if err != nil {
log.Fatal("error", err.Error())
return
}
}
```
# Create Customer
Source: https://docs.swervpay.co/api-reference/customers/create
POST /customers
create customers
```bash cURL theme={null}
curl -X POST https://api.swervpay.co/api/v1/customers \
-H "Authorization: Bearer " \
-H "Content-Type: application/json" \
-d '{
"firstname": "user",
"lastname": "user",
"middlename": "user",
"country": "user",
"email": "user@mailinator.com"
}'
```
```javascript Node.js theme={null}
import { SwervpayClient } from '@swervpaydev/sdk';
const config = {
secretKey: "",
businessId: ""
}
const swervpay = new SwervpayClient(config);
await swervpay.customer.create({
firstname: "user",
lastname: "user",
middlename: "user",
country: "user",
email: "user@mailinator.com"
})
```
```php PHP theme={null}
use Swervpaydev\SDK\Swervpay;
$config = [
'business_id' => '',
'secret_key' => ''
];
$client = new Swervpay($config);
$client->customer()->create([
"firstname" => "user",
"lastname" => "user",
"middlename" => "user",
"country" => "user",
"email" => "user@mailinator.com"
]);
```
```go Go theme={null}
package main
import (
"context"
"fmt"
"github.com/swerv-ltd/swervpay-go"
"log"
)
func main() {
ctx := context.Background()
client := swervpay.NewSwervpayClient(&swervpay.SwervpayClientOption{
BusinessID: "",
SecretKey: "",
})
data := swervpay.CreateCustomerBody{
Firstname: "user",
Lastname: "user",
Middlename: "user",
Country: "user",
Email: "user@mailinator.com"
}
resp, err := client.Customer.Create(ctx, data)
if err != nil {
log.Fatal("error", err.Error())
return
}
}
```
# Get Customer
Source: https://docs.swervpay.co/api-reference/customers/get
GET /customers/{id}
Get customer
```bash cURL theme={null}
curl -X GET https://api.swervpay.co/api/v1/customers/{id} \
-H "Authorization: Bearer " \
-H "Content-Type: application/json"
```
```javascript Node.js theme={null}
import { SwervpayClient } from '@swervpaydev/sdk';
const config = {
secretKey: "",
businessId: ""
}
const swervpay = new SwervpayClient(config);
await swervpay.customer.get('{id}')
```
```php PHP theme={null}
use Swervpaydev\SDK\Swervpay;
$config = [
'business_id' => '',
'secret_key' => ''
];
$client = new Swervpay($config);
$client->customer()->get('');
```
```go Go theme={null}
package main
import (
"context"
"fmt"
"github.com/swerv-ltd/swervpay-go"
"log"
)
func main() {
ctx := context.Background()
client := swervpay.NewSwervpayClient(&swervpay.SwervpayClientOption{
BusinessID: "",
SecretKey: "",
})
resp, err := client.Customer.Get(ctx, "")
if err != nil {
log.Fatal("error", err.Error())
return
}
}
```
# Get All Customers
Source: https://docs.swervpay.co/api-reference/customers/get-all-customers
GET /customers
Get customers
```bash cURL theme={null}
curl -X GET https://api.swervpay.co/api/v1/customers \
-H "Authorization: Bearer " \
-H "Content-Type: application/json"
```
```javascript Node.js theme={null}
import { SwervpayClient } from '@swervpaydev/sdk';
const config = {
secretKey: "",
businessId: ""
}
const swervpay = new SwervpayClient(config);
await swervpay.customer.gets()
```
```php PHP theme={null}
use Swervpaydev\SDK\Swervpay;
$config = [
'business_id' => '',
'secret_key' => ''
];
$client = new Swervpay($config);
$client->customer()->gets()->toArray();
```
```go Go theme={null}
package main
import (
"context"
"fmt"
"github.com/swerv-ltd/swervpay-go"
"log"
)
func main() {
ctx := context.Background()
client := swervpay.NewSwervpayClient(&swervpay.SwervpayClientOption{
BusinessId: businessId
SecretKey: secretKey
})
query := swervpay.PageAndLimitQuery{
Limit: 10,
Page: 1,
}
resp, err := client.Customer.Gets(ctx, query)
if err != nil {
log.Fatal("error", err.Error())
return
}
}
```
# Customer KYC
Source: https://docs.swervpay.co/api-reference/customers/kyc
POST /customers/{id}/kyc
Update customer kyc
```bash cURL theme={null}
curl -X POST https://api.swervpay.co/api/v1/customers/{id}/kyc \
-H "Authorization: Bearer " \
-H "Content-Type: application/json" \
-d '{
"tier": "FULL",
"information": {
"bvn": "12345678901",
"state": "Lagos",
"city": "Ikeja",
"country": "Nigeria",
"address": "No 1, Ikeja",
"postal_code": "100001",
"date_of_birth": "1990-01-01"
},
"document": {
"documentType": "PASSPORT",
"documentNumber": "A1234567",
"document": "https://example.com/document.jpg",
"passport": "https://example.com/passport.jpg"
}
}'
```
```javascript Node.js theme={null}
import { SwervpayClient } from '@swervpaydev/sdk';
const config = {
secretKey: "",
businessId: ""
}
const swervpay = new SwervpayClient(config);
await swervpay.customer.kyc("", {
tier: "FULL",
information: {
bvn: "12345678901",
state: "Lagos",
city: "Ikeja",
country: "Nigeria",
address: "No 1, Ikeja",
postal_code: "100001",
date_of_birth: "1990-01-01"
},
document: {
document_type: "PASSPORT",
document_number: "A1234567",
document: "https://example.com/document.jpg",
passport: "https://example.com/passport.jpg"
}
});
```
```php PHP theme={null}
use Swervpaydev\SDK\Swervpay;
$config = [
'business_id' => '',
'secret_key' => ''
];
$client = new Swervpay($config);
$client->customer()->kyc('', [
'tier' => 'FULL',
'information' => [
'bvn' => '12345678901',
'state' => 'Lagos',
'city' => 'Ikeja',
'country' => 'Nigeria',
'address' => 'No 1, Ikeja',
'postal_code' => '100001',
'date_of_birth' => '1990-01-01'
],
'document' => [
'document_type' => 'PASSPORT',
'document_number' => 'A1234567',
'document' => 'https://example.com/document.jpg',
'passport' => 'https://example.com/passport.jpg'
]
]);
```
```go Go theme={null}
package main
import (
"context"
"fmt"
"github.com/swerv-ltd/swervpay-go"
"log"
)
func main() {
ctx := context.Background()
client := swervpay.NewSwervpayClient(&swervpay.SwervpayClientOption{
BusinessID: "",
SecretKey: "",
})
data := swervpay.CustomerKycBody{
Tier: "FULL",
Tier1: swervpay.Tier1KycInput{
Bvn: "12345678901",
State: "Lagos",
City: "Ikeja",
Country: "Nigeria",
Address: "No 1, Ikeja",
PostalCode: "100001",
DateOfBirth: "1990-01-01",
},
Tier2: swervpay.Tier2KycInput{
DocumentType: "PASSPORT",
DocumentNumber: "A1234567",
Document: "https://example.com/document.jpg",
Passport: "https://example.com/passport.jpg",
},
}
resp, err := client.Customer.Kyc(ctx, "", data)
if err != nil {
log.Fatal("error", err.Error())
return
}
}
```
# Update Customer
Source: https://docs.swervpay.co/api-reference/customers/update
POST /customers/{id}/update
Update customer detail
```bash cURL theme={null}
curl -X POST https://api.swervpay.co/api/v1/customers/{id}/update \
-H "Authorization: Bearer " \
-H "Content-Type: application/json" \
-d '{
"phone_number": "user",
"email": "user@mailinator.com"
}'
```
```javascript Node.js theme={null}
import { SwervpayClient } from '@swervpaydev/sdk';
const config = {
secretKey: "",
businessId: ""
}
const swervpay = new SwervpayClient(config);
await swervpay.customer.update("", {
phone_number: "user",
email: "user@mailinator.com"
})
```
```php PHP theme={null}
use Swervpaydev\SDK\Swervpay;
$config = [
'business_id' => '',
'secret_key' => ''
];
$client = new Swervpay($config);
$client->customer()->update("", [
"phone_number" => "user",
"email" => "user@mailinator.com"
])->toArray();
```
```go Go theme={null}
package main
import (
"context"
"fmt"
"github.com/swerv-ltd/swervpay-go"
"log"
)
func main() {
ctx := context.Background()
client := swervpay.NewSwervpayClient(&swervpay.SwervpayClientOption{
BusinessID: "",
SecretKey: "",
})
data := swervpay.UpdateCustomerBody{
PhoneNumber: "user",
Email: "user@mailinator.com"
}
resp, err := client.Customer.Update(ctx, "", data)
if err != nil {
log.Fatal("error", err.Error())
return
}
}
```
# Create FX
Source: https://docs.swervpay.co/api-reference/fx/exchange
POST /fx/exchange
Create exchange
```bash cURL theme={null}
curl -X POST https://api.swervpay.co/api/v1/fx/exchange \
-H "Authorization: Bearer " \
-H "Content-Type: application/json" \
-d '{
"from": "NGN",
"to": "USD",
"amount": 1
}'
```
```javascript Node.js theme={null}
import { SwervpayClient } from '@swervpaydev/sdk';
const config = {
secretKey: "",
businessId: ""
}
const swervpay = new SwervpayClient(config);
await swervpay.fx.exchange({
amount: 100,
currency: 'NGN',
to: 'USD'
})
```
```php PHP theme={null}
use Swervpaydev\SDK\Swervpay;
$config = [
'business_id' => '',
'secret_key' => ''
];
$client = new Swervpay($config);
$client->fx()->exchange([
'amount' => 100,
'currency' => 'NGN',
'to' => 'USD'
]);
```
```go Go theme={null}
package main
import (
"context"
"fmt"
"github.com/swerv-ltd/swervpay-go"
"log"
)
func main() {
ctx := context.Background()
client := swervpay.NewSwervpayClient(&swervpay.SwervpayClientOption{
BusinessID: "",
SecretKey: "",
})
data := swervpay.FxBody{
Amount: 100,
Currency: "NGN",
To: "USD"
}
resp, err := client.Fx.Exchange(ctx, data)
if err != nil {
log.Fatal("error", err.Error())
return
}
}
```
# Get FX Rates
Source: https://docs.swervpay.co/api-reference/fx/rate
POST /fx/rate
Get exchange rate
```bash cURL theme={null}
curl -X POST https://api.swervpay.co/api/v1/fx/rate \
-H "Authorization: Bearer " \
-H "Content-Type: application/json" \
-d '{
"from": "NGN",
"to": "USD",
"amount": 1
}'
```
```javascript Node.js theme={null}
import { SwervpayClient } from '@swervpaydev/sdk';
const config = {
secretKey: "",
businessId: ""
}
const swervpay = new SwervpayClient(config);
await swervpay.fx.rate({
amount: 100,
currency: 'NGN',
to: 'USD'
})
```
```php PHP theme={null}
use Swervpaydev\SDK\Swervpay;
$config = [
'business_id' => '',
'secret_key' => ''
];
$client = new Swervpay($config);
$client->fx()->rate([
'amount' => 100,
'currency' => 'NGN',
'to' => 'USD'
]);
```
```go Go theme={null}
package main
import (
"context"
"fmt"
"github.com/swerv-ltd/swervpay-go"
"log"
)
func main() {
ctx := context.Background()
client := swervpay.NewSwervpayClient(&swervpay.SwervpayClientOption{
BusinessID: "",
SecretKey: "",
})
data := swervpay.FxBody{
Amount: 100,
Currency: "NGN",
To: "USD"
}
resp, err := client.Fx.Rate(ctx, data)
if err != nil {
log.Fatal("error", err.Error())
return
}
}
```
# BVN Verification
Source: https://docs.swervpay.co/api-reference/identity/bvn
POST /identity/bvn
BVN Verification
```bash cURL theme={null}
curl -X POST https://api.swervpay.co/api/v1/identity/bvn \
-H "Authorization: Bearer " \
-H "Content-Type: application/json"
-d '{
"number": "12345678901"
}'
```
```javascript Node.js theme={null}
import { SwervpayClient } from '@swervpaydev/sdk';
const config = {
secretKey: "",
businessId: ""
}
const swervpay = new SwervpayClient(config);
await swervpay.identity.bvn("")
```
```php PHP theme={null}
use Swervpaydev\SDK\Swervpay;
$config = [
'business_id' => '',
'secret_key' => ''
];
$client = new Swervpay($config);
$client->identity()->bvn("")->toArray();
```
```go Go theme={null}
package main
import (
"context"
"fmt"
"github.com/swerv-ltd/swervpay-go"
"log"
)
func main() {
ctx := context.Background()
client := swervpay.NewSwervpayClient(&swervpay.SwervpayClientOption{
BusinessID: "",
SecretKey: "",
})
resp, err := client.Identity.Bvn("")
if err != nil {
log.Fatal("error", err.Error())
return
}
}
```
# Introduction
Source: https://docs.swervpay.co/api-reference/introduction
Swervpay provides a REST API for businesses building payment and embedded finance products. You can create collections, issue customer USD collection accounts, manage wallets, create and manage virtual cards, perform payouts, verify customer identity, retrieve transactions, and subscribe to real-time webhooks.
The API uses bearer authentication and is available in sandbox and production environments. Use sandbox while integrating, then complete the go-live checklist before moving production traffic.
Version: 1.0
Production Base URL: `https://api.swervpay.co/api/v1`
Sandbox Base URL: `https://sandbox.swervpay.co/api/v1`
## Core resources
* [Authentication](/api-reference/authentication) - authenticate API requests.
* [Customers](/api-reference/customers/create) - create customers and submit KYC information.
* [Collections](/api-reference/collections/create) - create NGN and USD collection accounts.
* [Wallets](/api-reference/wallets/get-all-wallets) - view wallet balances and wallet activity.
* [Cards](/api-reference/cards/create) - create, fund, freeze, unfreeze, terminate, and withdraw from virtual cards.
* [Payouts](/api-reference/payouts/create) - send payouts to supported bank accounts.
* [Identity](/api-reference/identity/bvn) - verify BVN information.
* [Webhooks](/webhooks/introduction) - receive event updates for collections, payouts, cards, wallets, customers, and more.
# Get Invoice
Source: https://docs.swervpay.co/api-reference/invoices/get
GET /invoices/{id}
Get invoice
# Get All Invoices
Source: https://docs.swervpay.co/api-reference/invoices/get-all-invoices
GET /invoices
Get list of invoices
# Get banks
Source: https://docs.swervpay.co/api-reference/others/get-banks
GET /banks
Get banks
```bash cURL theme={null}
curl -X GET https://api.swervpay.co/api/v1/banks \
-H "Authorization: Bearer " \
-H "Content-Type: application/json"
```
```javascript Node.js theme={null}
import { SwervpayClient } from '@swervpaydev/sdk';
const config = {
secretKey: "",
businessId: ""
}
const swervpay = new SwervpayClient(config);
await swervpay.other.banks()
```
```php PHP theme={null}
use Swervpaydev\SDK\Swervpay;
$config = [
'business_id' => '',
'secret_key' => ''
];
$client = new Swervpay($config);
$client->other()->banks()->toArray();
```
```go Go theme={null}
package main
import (
"context"
"fmt"
"github.com/swerv-ltd/swervpay-go"
"log"
)
func main() {
ctx := context.Background()
client := swervpay.NewSwervpayClient(&swervpay.SwervpayClientOption{
BusinessID: "",
SecretKey: "",
})
resp, err := client.Other.Banks()
if err != nil {
log.Fatal("error", err.Error())
return
}
}
```
# Resolve Account Number
Source: https://docs.swervpay.co/api-reference/others/resolve-account-number
POST /resolve-account-number
Resolve bank account number
```bash cURL theme={null}
curl -X POST https://api.swervpay.co/api/v1/resolve-account-number \
-H "Authorization: Bearer " \
-H "Content-Type: application/json" \
-d '{
"account_number": "user",
"bank_code": "user"
}'
```
```javascript Node.js theme={null}
import { SwervpayClient } from '@swervpaydev/sdk';
const config = {
secretKey: "",
businessId: ""
}
const swervpay = new SwervpayClient(config);
await swervpay.other.resolve_account_number({
'account_number': 'user',
'bank_code': 'user'
})
```
```php PHP theme={null}
use Swervpaydev\SDK\Swervpay;
$config = [
'business_id' => '',
'secret_key' => ''
];
$client = new Swervpay($config);
$client->other()->resolve_account_number([
'account_number' => 'user',
'bank_code' => 'user
]);
```
```go Go theme={null}
package main
import (
"context"
"fmt"
"github.com/swerv-ltd/swervpay-go"
"log"
)
func main() {
ctx := context.Background()
client := swervpay.NewSwervpayClient(&swervpay.SwervpayClientOption{
BusinessID: "",
SecretKey: "",
})
data := swervpay.ResolveAccountNumberBody{
AccountNumber: "user",
BankCode: "user"
}
resp, err := client.Other.ResolveAccountNumber(ctx, data)
if err != nil {
log.Fatal("error", err.Error())
return
}
}
```
# Create payout
Source: https://docs.swervpay.co/api-reference/payouts/create
POST /payouts
Create payout
```bash cURL theme={null}
curl -X POST https://api.swervpay.co/api/v1/payouts \
-H "Authorization: Bearer " \
-H "Content-Type: application/json" \
-d '{
"bank_code": "user",
"account_number": "user",
"amount": "user",
"currency": "NGN",
"reference": "user",
"narration": "user",
}'
```
```javascript Node.js theme={null}
import { SwervpayClient } from '@swervpaydev/sdk';
const config = {
secretKey: "",
businessId: ""
}
const swervpay = new SwervpayClient(config);
await swervpay.payout.create({
bank_code: "user",
account_number: "user",
amount: "user",
currency: "NGN",
reference: "user",
narration: "user"
})
```
```php PHP theme={null}
use Swervpaydev\SDK\Swervpay;
$config = [
'business_id' => '',
'secret_key' => ''
];
$client = new Swervpay($config);
$client->payout()->create([
"bank_code" => "user",
"account_number" => "user",
"amount" => "user",
"currency" => "NGN",
"reference" => "user",
"naration" => "user"
]);
```
```go Go theme={null}
package main
import (
"context"
"fmt"
"github.com/swerv-ltd/swervpay-go"
"log"
)
func main() {
ctx := context.Background()
client := swervpay.NewSwervpayClient(&swervpay.SwervpayClientOption{
BusinessID: "",
SecretKey: "",
})
data := swervpay.CreatePayoutBody{
BankCode: "user",
AccountNumber: "user",
Amount: "user",
Currency: "NGN",
Reference: "user",
Narration: "user"
}
resp, err := client.Payout.Create(ctx, data)
if err != nil {
log.Fatal("error", err.Error())
return
}
}
```
# Get payout
Source: https://docs.swervpay.co/api-reference/payouts/get
GET /payouts/{id}
Get payout
```bash cURL theme={null}
curl -X GET https://api.swervpay.co/api/v1/payouts/{id} \
-H "Authorization: Bearer " \
-H "Content-Type: application/json"
```
```javascript Node.js theme={null}
import { SwervpayClient } from '@swervpaydev/sdk';
const config = {
secretKey: "",
businessId: ""
}
const swervpay = new SwervpayClient(config);
await swervpay.payout.get('{id}')
```
```php PHP theme={null}
use Swervpaydev\SDK\Swervpay;
$config = [
'business_id' => '',
'secret_key' => ''
];
$client = new Swervpay($config);
$client->payout()->get('');
```
```go Go theme={null}
package main
import (
"context"
"fmt"
"github.com/swerv-ltd/swervpay-go"
"log"
)
func main() {
ctx := context.Background()
client := swervpay.NewSwervpayClient(&swervpay.SwervpayClientOption{
BusinessID: "",
SecretKey: "",
})
resp, err := client.Payout.Get(ctx, "")
if err != nil {
log.Fatal("error", err.Error())
return
}
}
```
# Get Transaction
Source: https://docs.swervpay.co/api-reference/transactions/get
GET /transactions/{id}
Get transaction
```bash cURL theme={null}
curl -X GET https://api.swervpay.co/api/v1/transactions/{id} \
-H "Authorization: Bearer " \
-H "Content-Type: application/json"
```
```javascript Node.js theme={null}
import { SwervpayClient } from '@swervpaydev/sdk';
const config = {
secretKey: "",
businessId: ""
}
const swervpay = new SwervpayClient(config);
await swervpay.transaction.get('')
```
```php PHP theme={null}
use Swervpaydev\SDK\Swervpay;
$config = [
'business_id' => '',
'secret_key' => ''
];
$client = new Swervpay($config);
$client->transaction()->get('');
```
```go Go theme={null}
package main
import (
"context"
"fmt"
"github.com/swerv-ltd/swervpay-go"
"log"
)
func main() {
ctx := context.Background()
client := swervpay.NewSwervpayClient(&swervpay.SwervpayClientOption{
BusinessID: "",
SecretKey: "",
})
resp, err := client.Transaction.Get(ctx, "")
if err != nil {
log.Fatal("error", err.Error())
return
}
}
```
# Get All Transctions
Source: https://docs.swervpay.co/api-reference/transactions/get-all-transactions
GET /transactions
Get list of transactions
```bash cURL theme={null}
curl -X GET https://api.swervpay.co/api/v1/transactions \
-H "Authorization: Bearer " \
-H "Content-Type: application/json"
```
```javascript Node.js theme={null}
import { SwervpayClient } from '@swervpaydev/sdk';
const config = {
secretKey: "",
businessId: ""
}
const swervpay = new SwervpayClient(config);
await swervpay.transaction.gets()
```
```php PHP theme={null}
use Swervpaydev\SDK\Swervpay;
$config = [
'business_id' => '',
'secret_key' => ''
];
$client = new Swervpay($config);
$client->transaction()->gets()->toArray();
```
```go Go theme={null}
package main
import (
"context"
"fmt"
"github.com/swerv-ltd/swervpay-go"
"log"
)
func main() {
ctx := context.Background()
client := swervpay.NewSwervpayClient(&swervpay.SwervpayClientOption{
BusinessID: "",
SecretKey: "",
})
query := swervpay.PageAndLimitQuery{
Limit: 10,
Page: 1,
}
resp, err := client.Transaction.Gets(ctx, query)
if err != nil {
log.Fatal("error", err.Error())
return
}
}
```
# Simulate credit transaction
Source: https://docs.swervpay.co/api-reference/wallets/credit
POST /wallets/{id}/credit
Simulate credit transaction (Sandbox Only)
# Get Wallet
Source: https://docs.swervpay.co/api-reference/wallets/get
GET /wallets/{id}
Get wallet
```bash cURL theme={null}
curl -X GET https://api.swervpay.co/api/v1/wallets/{id} \
-H "Authorization: Bearer " \
-H "Content-Type: application/json"
```
```javascript Node.js theme={null}
import { SwervpayClient } from '@swervpaydev/sdk';
const config = {
secretKey: "",
businessId: ""
}
const swervpay = new SwervpayClient(config);
await swervpay.wallet.get('')
```
```php PHP theme={null}
use Swervpaydev\SDK\Swervpay;
$config = [
'business_id' => '',
'secret_key' => ''
];
$client = new Swervpay($config);
$client->wallet()->get('');
```
```go Go theme={null}
package main
import (
"context"
"fmt"
"github.com/swerv-ltd/swervpay-go"
"log"
)
func main() {
ctx := context.Background()
client := swervpay.NewSwervpayClient(&swervpay.SwervpayClientOption{
BusinessID: "",
SecretKey: "",
})
resp, err := client.Wallet.Get(ctx, "")
if err != nil {
log.Fatal("error", err.Error())
return
}
}
```
# Get All Wallets
Source: https://docs.swervpay.co/api-reference/wallets/get-all-wallets
GET /wallets
Get wallets
```bash cURL theme={null}
curl -X GET https://api.swervpay.co/api/v1/wallets \
-H "Authorization: Bearer " \
-H "Content-Type: application/json"
```
```javascript Node.js theme={null}
import { SwervpayClient } from '@swervpaydev/sdk';
const config = {
secretKey: "",
businessId: ""
}
const swervpay = new SwervpayClient(config);
await swervpay.wallet.gets()
```
```php PHP theme={null}
use Swervpaydev\SDK\Swervpay;
$config = [
'business_id' => '',
'secret_key' => ''
];
$client = new Swervpay($config);
$client->wallet()->gets()->toArray();
```
```go Go theme={null}
package main
import (
"context"
"fmt"
"github.com/swerv-ltd/swervpay-go"
"log"
)
func main() {
ctx := context.Background()
client := swervpay.NewSwervpayClient(&swervpay.SwervpayClientOption{
BusinessID: "",
SecretKey: "",
})
query := swervpay.PageAndLimitQuery{
Limit: 10,
Page: 1,
}
resp, err := client.Wallet.Gets(ctx, query)
if err != nil {
log.Fatal("error", err.Error())
return
}
}
```
# Retry Webhook Log
Source: https://docs.swervpay.co/api-reference/webhook/retry
POST /webhook/log/{id}/retry
Retry webhook log
```bash cURL theme={null}
curl -X POST https://api.swervpay.co/api/v1/webhook/{id}/retry \
-H "Authorization: Bearer " \
-H "Content-Type: application/json"
```
```javascript Node.js theme={null}
import { SwervpayClient } from '@swervpaydev/sdk';
const config = {
secretKey: "",
businessId: ""
}
const swervpay = new SwervpayClient(config);
await swervpay.webhook.retry('')
```
```php PHP theme={null}
use Swervpaydev\SDK\Swervpay;
$config = [
'business_id' => '',
'secret_key' => ''
];
$client = new Swervpay($config);
$client->webhook()->retry('');
```
```go Go theme={null}
package main
import (
"context"
"fmt"
"github.com/swerv-ltd/swervpay-go"
"log"
)
func main() {
ctx := context.Background()
client := swervpay.NewSwervpayClient(&swervpay.SwervpayClientOption{
BusinessID: "",
SecretKey: "",
})
resp, err := client.Webhook.Retry(ctx, "")
if err != nil {
log.Fatal("error", err.Error())
return
}
}
```
# Test Webhook
Source: https://docs.swervpay.co/api-reference/webhook/test
POST /webhook/{id}/test
Send test webhook
```bash cURL theme={null}
curl -X POST https://api.swervpay.co/api/v1/webhook/{id}/test \
-H "Authorization: Bearer " \
-H "Content-Type: application/json"
```
```javascript Node.js theme={null}
import { SwervpayClient } from '@swervpaydev/sdk';
const config = {
secretKey: "",
businessId: ""
}
const swervpay = new SwervpayClient(config);
await swervpay.webhook.test('');
```
```php PHP theme={null}
use Swervpaydev\SDK\Swervpay;
$config = [
'business_id' => '',
'secret_key' => ''
];
$client = new Swervpay($config);
$client->webhook()->test('');
```
```go Go theme={null}
package main
import (
"context"
"fmt"
"github.com/swerv-ltd/swervpay-go"
"log"
)
func main() {
ctx := context.Background()
client := swervpay.NewSwervpayClient(&swervpay.SwervpayClientOption{
BusinessID: "",
SecretKey: "",
})
resp, err := client.Webhook.Test(ctx, "")
if err != nil {
log.Fatal("error", err.Error())
return
}
}
```
# Overview
Source: https://docs.swervpay.co/card/introduction
Swerv Card API allows businesses to create card for their customer to pay anywhere global
This API provides a powerful, secure, and easy-to-use set of endpoints for card management, including creation, retrieval, freezing, and termination of cards. This guide will cover essential operations to help you manage card transactions within your applications
## Card Details Encryption
All card details are encrypted follows the AES standard with the following parameters:
* Algorithm: AES (RijndaelManaged)
* Mode: CBC (Cipher Block Chaining)
* Padding: PKCS7
* Block Size: 128-bit
* Key & IV: Derived from your registered Business ID:
* Key: The first 16 characters of your Business ID
* IV (Initialization Vector): The last 16 characters of your Business ID
```json Encrypted Card Details Payload theme={null}
{
"card_number": "1234567890123456",
"cvv": "123",
"expiry": "12/34",
"masked_pan": "424242******4242"
}
```
```javascript NodeJS theme={null}
const crypto = require('crypto');
function decryptStringAES(cipherText, clientId) {
const iv = Buffer.from(clientId.slice(0, 16), 'utf8');
const key = Buffer.from(clientId.slice(-16), 'utf8');
const encrypted = Buffer.from(cipherText, 'base64');
try {
const decipher = crypto.createDecipheriv('aes-128-cbc', key, iv);
let decrypted = decipher.update(encrypted);
decrypted = Buffer.concat([decrypted, decipher.final()]);
return JSON.parse(decrypted.toString());
} catch (err) {
return "keyError";
}
}
```
```go Go theme={null}
type CardInformation struct {
CardNumber string `json:"card_number"`
CardCvv string `json:"cvv"`
CardExpiry string `json:"expiry"`
MaskedPan string `json:"masked_pan"`
}
func decryptCardInformation(clientId, cipherText string) CardInformation {
iv := []byte(clientId[:16])
key := []byte(clientId[len(clientId)-16:])
encrypted, _ := base64.StdEncoding.DecodeString(cipherText)
block, err := aes.NewCipher(key)
if err != nil {
panic(err)
}
if len(encrypted)%aes.BlockSize != 0 {
panic("ciphertext not a multiple of block size")
}
mode := cipher.NewCBCDecrypter(block, iv)
decrypted := make([]byte, len(encrypted))
mode.CryptBlocks(decrypted, encrypted)
// remove PKCS7 padding
padLen := int(decrypted[len(decrypted)-1])
decrypted = decrypted[:len(decrypted)-padLen]
var details CardInformation
err = json.Unmarshal([]byte(decrypted), &details)
if err != nil {
panic(err)
}
return details
}
```
```php PHP theme={null}
function decryptStringAES($cipherText, $clientId) {
$iv = substr($clientId, 0, 16);
$key = substr($clientId, -16);
$cipherBytes = base64_decode($cipherText);
$decrypted = openssl_decrypt($cipherBytes, 'AES-128-CBC', $key, OPENSSL_RAW_DATA, $iv);
if ($decrypted === false) {
return "keyError";
}
return json_decode($decrypted, true);
}
```
### π Create a Card
Initiate the creation of a virtual or physical card by sending a request to the [create](/api-reference/cards/create) card endpoint.
**Parameters**
The unique identifier for the customer to whom the card will be issued.
The three-letter ISO currency code in uppercase.
The cardholder name that may appear on the card.
card provider e.g MASTERCARD, VISA
card type e.g DEFAULT, LITE or COOPERATE
amount to pre-fund the card
The expiry date of the card in the format YYYY-MM-DD.
Phone number of the cardholder (for cooperate & lite card type only)
RC Number of the company (for cooperate card type only)
BVN of the director of the company (for cooperate card type only)
Business email of the company (for cooperate card type only)
Document number of the company (for lite card type only)
Document type of the company (for lite card type only)
Note: `customer_id` is required for DEFAULT card type
**Request Body**
Provide necessary details to set up a new card.
```json theme={null}
{
"customer_id": "user",
"currency": "USD",
"issuer": "MASTERCARD",
"name_on_card": "Swerv",
"expiry_date": "2025-01-01",
"amount": 10,
"type": "DEFAULT"
}
```
### π³β Fund Card
Add funds to an existing card using the [fund](/api-reference/cards/fund) endpoint. This operation is essential for increasing the card's available balance for use.
**Parameters**
The unique identifier of the card to fund.
**Body**
The amount to fund in the smallest currency unit.
### π Get a Card
Retrieve information about a specific card with its unique identifier using the [get](/api-reference/cards/get) card endpoint.
**Parameters**
The unique identifier of the card to retrieve.
### βοΈ Freeze a Card
Temporarily disable a card to prevent new transactions by using the [freeze](/api-reference/cards/freeze) card endpoint.
**Path Parameters**
The unique identifier of the card to freeze/unfreeze.
### π« Terminate a Card
Permanently disable a card and remove it from your account with the [terminate](/api-reference/cards/terminate) card endpoint.
**Path Parameters**
The unique identifier of the card to terminate.
### πΈ Withdraw from Card
Withdraw funds from the card back to your business account using the [withdraw-from-card](/api-reference/cards/withdraw-from-card) endpoint.
**Path Parameters**
The unique identifier of the card to withdraw from.
**Body**
The amount to fund in the smallest currency unit.
### ποΈ Get All Cards
To retrieve a comprehensive list of all the cards, use the [get all](/api-reference/cards/get-all-cards) cards endpoint. This method provides a paginated list of cards, complete with details for each card, allowing for effective oversight and management.
**Query Parameters**
The page to return.
The maximum number of results to return.
**Response Example**
The response returns an array of card objects with their respective details.
```json theme={null}
[
{
"id": "card_123456789",
"type": "virtual",
"status": "active",
"card_number": "4242424242424242",
"expiry": "12/34",
"cvv": "123",
"name_on_card": "John Doe",
"balance": 500000, // Balance in the smallest currency unit
"total_funded": 1500000, // Total funded in the smallest currency unit
"freeze": false,
"address_street": "123 Swyft Street",
"address_city": "Paytown",
"address_state": "Paystate",
"address_country": "NG",
"address_postal_code": "123456",
"created_at": "2024-01-01T00:00:00Z",
"updated_at": "2024-01-02T00:00:00Z",
"masked_pan": "424242******4242"
}
// ...other cards
]
```
# 2024 Changelog
Source: https://docs.swervpay.co/changelog/introduction
Stay up to date with the latest changes to our services
## August 2024
* Added [bvn verification](api-reference/identity/bvn) endpoint
* Update [create collection](api-reference/collections/create) endpoint to support additional information
* Update NodeJS sdk to support new changes
* Added unfreeze card endpoint
* Updated collection webhook
## July 2024
* Added support for IP whitelisting in dashboard
* Update get transaction to include collection details for collection transactions
* Update NodeJS sdk to support new changes
## June 2024
* Improve card issuance endpoint
## May 2024
* Update customer kyc to support voter's card
* Improve card issuance endpoint
## April 2024
* Added support for sandbox in all sdks
## March 2024
* (Sandbox Only) Added credit simulate for [wallet](api-reference/collections/credit), [collection](api-reference/wallets/credit), and [checkout](api-reference/checkouts/credit).
* Added sandbox endpoint for testing ([https://sandbox.swervpay.co/api/v1](https://sandbox.swervpay.co/api/v1))
## February 2024
* Added [NodeJS](https://www.npmjs.com/package/@swervpaydev/sdk) Sdk support
* Added [Go](https://github.com/Swerv-Ltd/swervpay-go) Sdk support
* Added [PHP](https://packagist.org/packages/swervpaydev/sdk) Sdk support
* Added [Laravel](https://packagist.org/packages/swervpaydev/laravel) Sdk support
## Jauary 2024
* Kick off the project
# Overview
Source: https://docs.swervpay.co/collection/introduction
Swerv Collection allows businesses to accept payments from their customers using virtual accounts & payment link.
## Supported partners
Below are the list of currently supported partners for virtual account issuing
* VFD Microfinance Bank
* Bridge for USD collection accounts
## Create Virtual Account
To create a virtual account, use the [create](/api-reference/collections/create) collection endpoint.
**Parameters**
The unique identifier for the customer to whom the card will be issued.
The three-letter ISO currency code in uppercase. Use `NGN` for Naira accounts and `USD` for USD collection accounts.
merchant name that will be displayed on the virtual account. Required for ONE\_TIME (Temporary) virtual account.
virtual account type e.g DEFAULT (Permanent), ONE\_TIME (Temporary)
amount expected to be paid into the virtual account. Required for ONE\_TIME (Temporary) virtual account.
Required when `currency` is `USD`. This contains the customer identity, address, document, source of funds, and supporting document details required for USD account issuance.
Note: `customer_id` is required for `DEFAULT` permanent virtual accounts.
```JSON Request Body theme={null}
{
"customer_id": "user",
"currency": "NGN",
"merchant_name": "Swerv",
"amount": 10,
"type": "ONE_TIME"
}
```
### USD collection accounts
USD collection accounts are issued through Swervpay's Bridge-backed collection flow. Before creating a USD collection account, create the customer and submit customer KYC. Then create a `DEFAULT` collection with `currency` set to `USD` and include the required `additional_information` payload.
USD account issuance can be asynchronous. If the customer is already approved, the account details may be available shortly after creation. If additional review is required, listen for the `collection.created` or `collection.created.failed` webhook event.
```json USD Request Body theme={null}
{
"customer_id": "cus_123456789",
"currency": "USD",
"merchant_name": "Ada Okafor",
"amount": 0,
"type": "DEFAULT",
"additional_information": {
"account_type": "INDIVIDUAL",
"nin": "12345678901",
"tax_number": "12345678901",
"date_of_birth": "1994-04-12",
"employment_status": "EMPLOYED",
"account_designation": "PERSONAL",
"income_band": "UNDER_10000",
"source_of_income": "SALARY",
"address": {
"street": "12 Admiralty Way",
"city": "Lagos",
"state": "Lagos",
"country": "Nigeria",
"zip_code": "100001"
},
"document": {
"type": "NIN",
"number": "12345678901",
"issue_date": "2020-01-01",
"expiry_date": "2030-01-01",
"urls": ["https://example.com/document-front.jpg"]
},
"utility_bill": "https://example.com/utility-bill.pdf",
"bank_statement": "https://example.com/bank-statement.pdf"
}
}
```
Swervpay securely submits the required customer data to Bridge, creates or reuses the Bridge customer profile, and issues the USD deposit account when the customer is approved.
### π Get Collection Details
Retrieve detailed information of a specific collection with their unique identifier using the [get](/api-reference/collections/get) collection endpoint.
**Path Parameters**
The unique identifier of the collection to retrieve.
### π Get All collections
Retrieve a list of all collections by sending a request to the [get all](/api-reference/collections/get-all-collections) collections endpoint.
**Query Parameters**
The page to return.
The maximum number of results to return.
**Response Example**
The response provides an array of wallet objects, each containing comprehensive details about the wallets associated with your Swerv account.
```json Response theme={null}
[
{
"account_name": "string",
"account_number": "string",
"account_type": "string",
"balance": 100000, // Balance in the smallest currency unit
"bank_address": "string",
"bank_code": "string",
"bank_name": "string",
"created_at": "2024-01-01T00:00:00Z",
"id": "wlt_123456789",
"is_blocked": false,
"pending_balance": 50000, // Pending balance in the smallest currency unit
"reference": "string",
"routing_number": "string",
"total_received": 1500000, // Total amount received in the smallest currency unit
"updated_at": "2024-01-02T00:00:00Z"
}
// ...other wallets
]
```
# Overview
Source: https://docs.swervpay.co/customer/introduction
Manage your customers efficiently with the Swerv Customers API.
### π€ Create a Customer
To add a new customer to your system, use the [create](/api-reference/customers/create) customer endpoint.
**Body**
The customer's first name. It must match the customer's government-issued identification for KYC purposes.
The customer's last name or surname. It must match the customer's government-issued identification for KYC purposes.
The customer's middle name or initial. This can be used for additional verification and should match the customer's government-issued identification if provided.
The country of the customer's residence or operation. Use ISO 3166-1 alpha-2 country codes.
The customer's email address.
**Request Body**
Provide necessary details to set up a new card.
```json Request Body theme={null}
{
"firstname": "user",
"lastname": "user",
"middlename": "user",
"country": "user",
"email": "user@mailinator.com"
}
```
### π Get Customer Details
Retrieve detailed information of a specific customer with their unique identifier using the [get](/api-reference/customers/get) customer endpoint.
**Path Parameters**
The unique identifier of the customer to retrieve.
### π Get All Customers
Retrieve a comprehensive list of all customers in your system using the [get](/api-reference/customers/get-all-customers) all customers endpoint.
**Query Parameters**
The page to return.
The maximum number of results to return.
## Perform KYC for a Customer
Conduct Know Your Customer (KYC) checks to verify the identity of your customers using the [customer KYC](/api-reference/customers/kyc) endpoint.
Customer KYC is required before issuing a `DEFAULT` USD collection account for a customer. After KYC is submitted, create a USD collection with `currency` set to `USD` and include the required `additional_information` payload.
**Parameters**
The unique identifier of the customer to retrieve.
**Body**
* `tier` enum (ONE, TWO, FULL) :
* The amount to fund in the smallest currency unit.
* `information` object :
* `bvn` string : customer bvn (Nigeria)
* `ssnit` string : customer ssnit (Ghana)
* `state` string : customer state
* `city` string : customer city
* `country` string : customer country
* `address` string : customer address
* `postal_code` string : customer address postal code
* `date_of_birth` string : customer date of birth
* `document` object :
* `document_type` enum (NIN, PASSPORT, DRIVERS\_LICENSE)
* `document_number` number : customer document number
* `document` url : customer document url
* `passport` url : customer passport photograph url
```JSON Request Body theme={null}
{
"tier": "FULL",
"information": {
"bvn": "12345678901",
"state": "Lagos",
"city": "Ikeja",
"country": "Nigeria",
"address": "No 1, Ikeja",
"postal_code": "100001",
"date_of_birth": "1990-01-01",
"phone_number": "08012345678"
},
"document": {
"document_type": "PASSPORT",
"document_number": "A1234567",
"document": "https://example.com/document.jpg",
"passport": "https://example.com/passport.jpg"
}
}
```
## Blacklist Customer
Blacklist customer from performing any action using the [post](/api-reference/customers/blacklist).
**Parameters**
The unique identifier of the customer to blacklist.
# Overview
Source: https://docs.swervpay.co/fx/introduction
Converting from one currency to another get easier with Swerv
### Supported Conversion
* USD to NGN
* NGN to USD
### π΅ Get Rate
To get current rate for convertion, use the [rate](/api-reference/fx/rate) endpoint.
**Body**
The three-letter ISO currency code in uppercase.
The three-letter ISO currency code in uppercase.
amount to convert in the smallest currency unit (e.g., cents, kobo).
```json Request Body theme={null}
{
"from": "NGN",
"to": "USD",
"amount": 1
}
```
### π΅ Exchnage
To convert from one currency to another, use the [exchange](/api-reference/fx/exchange) endpoint.
**Body**
The three-letter ISO currency code in uppercase.
The three-letter ISO currency code in uppercase.
amount to convert in the smallest currency unit (e.g., cents, kobo).
```json Request Body theme={null}
{
"from": "NGN",
"to": "USD",
"amount": 1
}
```
# Go live checklist
Source: https://docs.swervpay.co/go-live-checklist
A checklist of things to do before going live (production) with Swervpay.
## List
After create account, you will be redirected to the dashboard. Click on the [Create Business](https://app.swervpay.co/businesses/new) button to create a business.
After creating a business, you will be redirected to the business dashboard. On the business homepage click continue kyc button to complete the business KYC.
If you have a team member you want to invite to the business, you can do so by clicking on the [Invite Team Member](https://app.swervpay.co/~/settings/teams) button on the business dashboard.
It is recommended to setup a webhook to receive event notification from Swervpay. You can do this by going to the developer section of the dashboard and clicking on the [Create Webhook](https://app.swervpay.co/~/developers/webhooks) button and make sure to run send test so as to conduct proper test for event communication.
Toggle the live button in the developer section of the dashboard to go live.
# Introduction
Source: https://docs.swervpay.co/introduction
Welcome to the Swervpay developer documentation. Swervpay gives businesses one API layer for building financial products across collections, payouts, cards, wallets, customers, identity verification, FX, and webhooks.
Use Swervpay to create NGN collection accounts, issue USD collection accounts for verified customers, manage customer profiles and KYC, create and fund virtual cards, move money to bank accounts, verify BVNs, and receive real-time event updates through webhooks. The API is designed for teams building payment, treasury, marketplace, remittance, and embedded finance workflows.
Start with the [Quickstart](/quickstart) if you want to make your first API call, or go directly to the [API Reference](/api-reference/introduction) for endpoint-level documentation.
## Resources
Explore our SDKs to get started with your favorite language
Explore endpoints for collections, payouts, cards, customers, wallets, FX, identity, and webhooks
Stay up to date with the latest changes to our services
Having trouble? Reach out to our support team
# Overview
Source: https://docs.swervpay.co/payout/introduction
Swerv Payouts API allows businesses to automate and manage payout processes efficiently, ensuring fast, secure, and reliable transactions. This guide covers how to create a payout and retrieve payout details using our API
### Supported Currencies
The Swerv Payouts API currently supports the following currencies:
β’ **Nigerian Naira (NGN)**
β’ **United States Dollar (USD) (π§ Coming Soon)**
β’ **Euro (EUR) (π§ Coming Soon)**
β’ **British Pound (GBP) (π§ Coming Soon)**
### Supported Banks for Naira Bank Transfer
The Swerv Payouts API currently supports the following banks for Naira Bank Transfer:
| Bank Name | Bank Code |
| ------------------------ | --------- |
| Access Bank | 044 |
| Citibank | 023 |
| Diamond Bank | 063 |
| Ecobank Nigeria | 050 |
| Fidelity Bank Nigeria | 070 |
| First Bank of Nigeria | 011 |
| First City Monument Bank | 214 |
| Guaranty Trust Bank | 058 |
Retrieve the full list of supported banks using the [list](/api-reference/others/get-banks) banks endpoint.
### Create a Payout
To initiate a payout, use the [create](/api-reference/payouts/create) payout endpoint. This method allows you to send funds to a specified bank account. We currently support:
β’ **Naira Bank Transfer**
**Parameters**
A unique bank code.
The recipient's bank account number.
The total payout amount in the smallest currency unit (e.g., cents, kobo).
The three-letter ISO currency code in uppercase.
A unique identifier for the transaction.
A description for the transaction, to appear on the recipientβs statement.
***
**Request Body**
Provide details of the payout, including the recipient's bank information, amount, and currency
```json Request Body theme={null}
{
"bank_code": "059",
"account_number": "0690000000",
"amount": 8500,
"currency": "NGN",
"reference": "reference",
"naration": "narration",
}
```
### Get a Payout
Retrieve details of a specific payout using its unique ID with the [get](/api-reference/payouts/get) payout endpoint.
**Path Parameters**
The unique identifier of the payout to retrieve.
# Quickstart
Source: https://docs.swervpay.co/quickstart
This guides demonstrate how to use Swervpay NodeJS SDK to integrate Swervpay into your NodeJS application.
### Setup
Make sure you have create a Swervpay business and have your API keys ready. Don't forget to check our recommended [go live checklist](/go-live-checklist).
### Install the SDK
Install [swervpay-node](https://www.npmjs.com/package/@swervpaydev/sdk) sdk into your new or existing NodeJS application using any of your favorite package manager.
```bash npm theme={null}
$ npm install @swervpaydev/sdk
```
```bash yarn theme={null}
$ yarn add @swervpaydev/sdk
```
```bash pnpm theme={null}
$ pnpm add @swervpaydev/sdk
```
```bash bun theme={null}
$ bun install @swervpaydev/sdk
```
### Usage
```javascript NodeJS theme={null}
import { SwervpayClient } from "@swervpaydev/sdk";
const config = {
secretKey: "",
businessId: ""
}
const swervpay = new SwervpayClient(config);
// Create a new customer
await swervpay.customer.create({
firstname: "user",
lastname: "user",
middlename: "user",
country: "user",
email: "user@mailinator.com"
})
// Create a new card
await swervpay.card.create({
customer_id: "user",
amount: 10,
currency: "USD",
provider: "MASTERCARD",
type: "DEFAULT"
})
// Create a USD collection account for a customer
await swervpay.collection.create({
customer_id: "user",
currency: "USD",
merchant_name: "Ada Okafor",
amount: 0,
type: "DEFAULT",
additional_information: {
account_type: "INDIVIDUAL",
nin: "12345678901",
tax_number: "12345678901",
date_of_birth: "1994-04-12",
employment_status: "EMPLOYED",
account_designation: "PERSONAL",
income_band: "UNDER_10000",
source_of_income: "SALARY",
address: {
street: "12 Admiralty Way",
city: "Lagos",
state: "Lagos",
country: "Nigeria",
zip_code: "100001"
},
document: {
type: "NIN",
number: "12345678901",
issue_date: "2020-01-01",
expiry_date: "2030-01-01",
urls: ["https://example.com/document-front.jpg"]
},
utility_bill: "https://example.com/utility-bill.pdf",
bank_statement: "https://example.com/bank-statement.pdf"
}
})
// Create a new payout
await swervpay.payout.create({
bank_code: "user",
account_number: "user",
amount: "user",
currency: "NGN",
reference: "user",
narration: "user"
})
```
Here, we initialize the Swervpay client with our secret key and business id. Then we create a new customer, card, USD collection account, and payout.
### Next Steps
* [Go Live Checklist](/go-live-checklist)
* [API Reference](/api-reference)
### Other SDKs
* [PHP](https://packagist.org/packages/swervpaydev/sdk)
* [Laravel](https://packagist.org/packages/swervpaydev/laravel)
* [Go](https://github.com/swerv-ltd/swervpay-go)
# Dart
Source: https://docs.swervpay.co/sdks/dart
Dart Client for Swervpay
### Installation
Install [swervpay-dart](https://pub.dev/packages/swervpay_dart) sdk into your new or existing Flutter/Dart application.
```bash Shell theme={null}
$ flutter pub add swervpay_dart
# OR
$ dart pub add swervpay_dart
```
### Usage
```dart Dart/Flutter theme={null}
import 'package:swervpay_dart/swervpay_dart.dart';
void main() async {
final swervpay = Swervpay(
apiKey
);
}
```
# Go
Source: https://docs.swervpay.co/sdks/go
Go Client for Swervpay
### Installation
Install [swervpay-go](https://github.com/swerv-ltd/swervpay-go) sdk into your new or existing Go application.
```bash Shell theme={null}
$ go get github.com/swerv-ltd/swervpay-go
```
### Usage
```go Go theme={null}
package main
import (
"context"
"fmt"
"github.com/swerv-ltd/swervpay-go"
"os"
)
func main() {
ctx := context.Background()
businessId := os.Getenv("SWERVPAY_BUSINESS_ID")
secretKey := os.Getenv("SWERVPAY_SECRET_KEY")
client := swervpay.NewSwervpayClient(&swervpay.SwervpayClientOption{
BusinessID: businessId,
SecretKey: secretKey,
})
customers, err := client.Customer.Gets(ctx, &swervpay.PageAndLimitQuery{
Page: 1,
Limit: 10,
})
if err != nil {
panic(err)
}
for _, customer := range *customers {
fmt.Printf("%v\n", customer)
}
customer, err := client.Customer.Get(ctx, "cus_123456")
if err != nil {
panic(err)
}
fmt.Printf("%v\n", customer)
newCustomer, err := client.Customer.Create(ctx, &swervpay.CreateCustomerBody{
Firstname: "John",
Lastname: "Doe",
Middlename: "Doe",
Email: "johndoe@gmail.com",
Country: "Nigeria",
})
if err != nil {
panic(err)
}
fmt.Println("Created Customer id: " + newCustomer.ID)
fmt.Printf("%v\n", newCustomer)
banks, err := client.Other.Banks(ctx)
if err != nil {
panic(err)
}
for _, bank := range *banks {
fmt.Printf("%v\n", bank)
}
resolveAccount, err := client.Other.ResolveAccountNumber(ctx, swervpay.ResolveAccountNumberBody{
BankCode: "044",
AccountNumber: "0690000031",
})
if err != nil {
panic(err)
}
fmt.Printf("%v\n", resolveAccount)
transactions, err := client.Transaction.Gets(ctx, &swervpay.PageAndLimitQuery{
Page: 1,
Limit: 10,
})
if err != nil {
panic(err)
}
for _, transaction := range *transactions {
fmt.Printf("%v\n", transaction)
}
transaction, err := client.Transaction.Get(ctx, "txn_123456")
if err != nil {
panic(err)
}
fmt.Printf("%v\n", transaction)
}
```
See more [examples](https://github.com/Swerv-Ltd/swervpay-go/tree/main/_examples)
# Introduction
Source: https://docs.swervpay.co/sdks/introduction
Official SDks for Swervpay
## Official SDKs
}
href="/sdks/nodejs"
>
Official SDK for NodeJS.
}
href="/sdks/go"
>
Official SDK for GO.
}
href="/sdks/php"
>
Official SDK for PHP.
Official SDK for Laravel.
}
href="/sdks/dart"
>
Official SDK for Dart/Flutter.
# Laravel
Source: https://docs.swervpay.co/sdks/laravel
Laravel Client for Swervpay
### Installation
Install [swervpay-laravel](https://packagist.org/packages/swervpaydev/laravel) sdk into your new or existing Laravel application using composer.
```bash Shell theme={null}
$ composer require swervpaydev/laravel
```
### Configuration
You can publish the configuration file using this command:
```bash Shell theme={null}
$ php artisan vendor:publish --tag="swervpaydev-laravel-config"
```
Set `SWERVPAYDEV_SECRET_KEY` & `SWERVPAYDEV_BUSINESS_ID` value in your environmental variable file
### Usage
```php Laravel theme={null}
use Swervpaydev\SDK\Swervpay;
```
# NodeJS
Source: https://docs.swervpay.co/sdks/nodejs
NodeJS Client for Swervpay
### Installation
Install [swervpay-node](https://www.npmjs.com/package/@swervpaydev/sdk) sdk into your new or existing NodeJS application using any of your favorite package manager.
```bash Shell theme={null}
$ npm install @swervpaydev/sdk
$ yarn add @swervpaydev/sdk
$ pnpm add @swervpaydev/sdk
$ bun install @swervpaydev/sdk
```
### Usage
Create swervpay instance with your Business ID and secret.
```javascript NodeJS theme={null}
import { SwervpayClient } from "@swervpaydev/sdk";
const swervpay = new SwervpayClient({
businessId: process.env.SWERVPAY_API_KEY!,
secretKey: process.env.SWERVPAY_API_SECRET!,
logLevel: "debug",
});
```
### Create a Payout
Create a new payout
```javascript NodeJS theme={null}
const payout = await swervpay.payout.create({
amount: req.body.amount,
currency: req.body.currency,
bank_code: req.body.bank_code,
account_number: req.body.account_number,
naration: req.body.narration,
email: req.body.email,
reference: req.body.reference,
});
```
### Get payout
Get a payout
```javascript NodeJS theme={null}
const payout = await swervpay.payout.get(req.param.id);
```
### Get transactions
Retrieve all transactions
```javascript NodeJS theme={null}
const transactions = await swervpay.transaction.gets({
limit: parseInt(req.query.limit as string),
page: parseInt(req.query.page as string),
});
```
### Get transaction
Get a transaction
```javascript NodeJS theme={null}
const transaction = await swervpay.transaction.get(req.param.id);
```
### Create a customer
Create a new customer
```javascript NodeJS theme={null}
const customer = await swervpay.customer.create({
firstname: req.body.first_name,
lastname: req.body.last_name,
email: req.body.email,
middlename: "",
country: req.body.country,
});
```
### Update a customer
Update a customer
```javascript NodeJS theme={null}
const customer = await swervpay.customer.update(req.params.id, {
email: req.body.email,
phone_number: req.body.phone_number,
});
```
### Complete customer KYC
Create/Update customer KYC
```javascript NodeJS theme={null}
const customer = await swervpay.customer.kyc(req.params.id, {
tier: req.body.tier as "ONE" | "TWO" | "FULL",
document: {
document_type: req.body.document_type,
document: req.body.document,
passport: req.body.passport,
document_number: req.body.document_number,
},
information: {
address: req.body.address,
city: req.body.city,
bvn: req.body.bvn,
state: req.body.state,
country: req.body.country,
postal_code: req.body.postal_code,
},
});
```
### Get customers
Retrieve all customers
```javascript NodeJS theme={null}
const customers = await swervpay.customer.gets({
limit: parseInt(req.query.limit as string),
page: parseInt(req.query.page as string),
});
```
### Get customer
Get a customer
```javascript NodeJS theme={null}
const customer = await swervpay.customer.get(req.param.id);
```
### Create a card
Create a new card
```javascript NodeJS theme={null}
const card = await swervpay.card.create({
amount: req.body.amount,
currency: req.body.currency,
customer_id: req.body.customer_id,
type: req.body.type as "LITE" | "DEFAULT" | "COOPERATE",
issuer: req.body.issuer as "MASTERCARD" | "VISA",
name_on_card: req.body.name_on_card,
});
```
### Get cards
Retrieve all cards
```javascript NodeJS theme={null}
const cards = await swervpay.card.gets({
limit: parseInt(req.query.limit as string),
page: parseInt(req.query.page as string),
});
```
### Get card
Get a card
```javascript NodeJS theme={null}
const card = await swervpay.card.get(req.param.id);
```
### Webhook test
Send a test webhook
```javascript NodeJS theme={null}
await swervpay.webhook.test(req.params.id);
```
### Webhook retry
Retry a webhook log
```javascript NodeJS theme={null}
await swervpay.webhook.retry(req.params.id);
```
### Get banks
Retrieve all banks
```javascript NodeJS theme={null}
const banks = await swervpay.other.banks();
```
### Resolve account number
Resolve an account number
```javascript NodeJS theme={null}
const result = await swervpay.other.resolve_account_number({
bank_code: req.body.bank_code as string,
account_number: req.body.account_number as string,
});
```
### FX rate
Get the current exchange rate
```javascript NodeJS theme={null}
const result = await swervpay.fx.rate({
from: req.body.bank_code as string,
to: req.body.account_number as string,
amount: req.body.amount as number,
});
```
### FX Exchnage
Create a swap transaction
```javascript NodeJS theme={null}
const result = await swervpay.fx.rate({
from: req.body.bank_code as string,
to: req.body.account_number as string,
amount: req.body.amount as number,
});
```
### Get wallet
Get a wallet
```javascript NodeJS theme={null}
const wallet = await swervpay.wallet.get(req.params.id);
```
### Get wallets
Retrieve all wallets
```javascript NodeJS theme={null}
const wallets = await swervpay.wallet.gets({
limit: parseInt(req.query.limit as string),
page: parseInt(req.query.page as string),
});
```
See more [examples](https://github.com/Swerv-Ltd/swervpay-node/tree/main/examples)
# PHP
Source: https://docs.swervpay.co/sdks/php
PHP Client for Swervpay
### Installation
Install [swervpay-php](https://packagist.org/packages/swervpaydev/sdk) sdk into your new or existing PHP application using composer.
```bash Shell theme={null}
$ composer require swervpaydev/sdk
```
### Usage
```php PHP theme={null}
use Swervpaydev\SDK\Swervpay;
```
# Overview
Source: https://docs.swervpay.co/transaction/introduction
The Transaction API facilitates the retrieval, and management of financial transaction records.
### π Get All Transactions
'Retrieve a list of all transactions processed through Swervpay using the [get](/api-reference/transactions/get-all-transactions) all transaction endpoint which includes details such as transaction amount, status, and associated customer.
**Query Parameters**
The page to return.
The maximum number of results to return.
**Response Example**
Returns an array of transaction objects, each containing details about individual transactions processed through the platform.
```json Response theme={null}
[
{
"account_name": "Jane Doe",
"account_number": "1234567890",
"amount": 5000,
"bank_code": "string",
"bank_name": "Bank name",
"category": "transfer",
"charges": 50,
"created_at": "2024-01-01T12:00:00Z",
"detail": "Payment for services",
"fiat_rate": 1.0,
"id": "trans_789",
"reference": "ref_101112",
"report": false,
"report_message": "",
"session_id": "session_213",
"status": "completed",
"type": "debit",
"updated_at": "2024-01-02T12:00:00Z",
}
]
```
### π Get Transactions
Retrieve details of a specific transaction using its unique ID with the [get](/api-reference/transactions/get) transaction endpoint.
**Path Parameters**
The unique identifier of the transaction to retrieve.
**Response Example**
Retunrs a transaction object containing details about the transaction
```json Response theme={null}
{
"account_name": "Jane Doe",
"account_number": "1234567890",
"amount": 5000,
"bank_code": "string",
"bank_name": "Bank name",
"category": "transfer",
"charges": 50,
"created_at": "2024-01-01T12:00:00Z",
"customer_id": "cust_456",
"detail": "Payment for services",
"fiat_rate": 1.0,
"id": "trans_789",
"reference": "ref_101112",
"report": false,
"report_message": "",
"session_id": "session_213",
"status": "completed",
"type": "debit",
"updated_at": "2024-01-02T12:00:00Z",
}
```
# Overview
Source: https://docs.swervpay.co/wallet/introduction
Retrieve a list of all wallets associated with an account.
This API allows businesses to view wallet balances and transaction histories.
### π Get All wallets
Retrieve a list of all wallets by sending a request to the [get all](/api-reference/wallets/get-all-wallets) wallets endpoint. This enables businesses to monitor wallet statuses and balances in real-time.
**Query Parameters**
The page to return.
The maximum number of results to return.
**Response Example**
The response provides an array of wallet objects, each containing comprehensive details about the wallets associated with your Swervpay account.
```json Response theme={null}
[
{
"account_name": "string",
"account_number": "string",
"account_type": "string",
"balance": 100000, // Balance in the smallest currency unit
"bank_address": "string",
"bank_code": "string",
"bank_name": "string",
"created_at": "2024-01-01T00:00:00Z",
"id": "wlt_123456789",
"is_blocked": false,
"pending_balance": 50000, // Pending balance in the smallest currency unit
"reference": "string",
"routing_number": "string",
"total_received": 1500000, // Total amount received in the smallest currency unit
"updated_at": "2024-01-02T00:00:00Z"
}
// ...other wallets
]
```
# Card
Source: https://docs.swervpay.co/webhooks/card
Overview of Card Webhook Events
## Overview
Our card webhook events are fired based on the following triggers:
* Created webhook event
* Terminated webhook event
* Freeze webhook event
* Unfreeze webhook event
* Updated webhook event
* Transaction webhook event
* Charges webhook event
* Contactless activation webhook event
## Created webhook event
This event is fired when a card is created.
```json card.created theme={null}
{
"event": "card.created",
"data": {
"id": "card_123456789",
"business_id": "bus_mviuNSMKi74vTY8yvfP6nQ",
"status": "STATUS",
"created_at": "2024-02-06T02:49:18Z",
"updated_at": "2024-02-06T02:49:18Z"
}
}
```
## Terminated webhook event
This event is fired when a card is terminated.
```json card.terminated theme={null}
{
"event": "card.terminated",
"data": {
"id": "card_123456789",
"business_id": "bus_mviuNSMKi74vTY8yvfP6nQ",
"status": "STATUS",
"created_at": "2024-02-06T02:49:18Z",
"updated_at": "2024-02-06T02:49:18Z"
}
}
```
## Freeze webhook event
This event is fired when a card is freezed.
```json card.freezed theme={null}
{
"event": "card.freezed",
"data": {
"id": "card_123456789",
"business_id": "bus_mviuNSMKi74vTY8yvfP6nQ",
"balance": 1000,
"status": "STATUS",
"created_at": "2024-02-06T02:49:18Z",
"updated_at": "2024-02-06T02:49:18Z"
}
}
```
## Unfreeze webhook event
This event is fired when a card is unfreezed.
```json card.unfreezed theme={null}
{
"event": "card.unfreezed",
"data": {
"id": "card_123456789",
"business_id": "bus_mviuNSMKi74vTY8yvfP6nQ",
"balance": 1000,
"status": "STATUS",
"created_at": "2024-02-06T02:49:18Z",
"updated_at": "2024-02-06T02:49:18Z"
}
}
```
## Updated webhook event
This event is fired when a card is funded.
```json card.updated theme={null}
{
"event": "card.updated",
"data": {
"id": "card_123456789",
"business_id": "bus_mviuNSMKi74vTY8yvfP6nQ",
"balance": 1000,
"status": "ACTIVE",
"created_at": "2024-02-06T02:49:18Z",
"updated_at": "2024-02-06T02:49:18Z"
}
}
```
## Transaction webhook event
This event is fired when a card transaction is made.
### Transaction Categories
* FUNDING
* WITHDRAW
* Transaction
### Transaction Types
* DEBIT
* CREDIT
### Transaction Status
* APPROVED
* DECLINED
* COMPLETED
* FAILED
* REVERSE
```json card.transaction theme={null}
{
"event": "card.transaction",
"data": {
"id": "card_123456789",
"card_id": "card_123456789",
"business_id": "bus_mviuNSMKi74vTY8yvfP6nQ",
"reference": "ref_mviuNSMKi74vTY8yvfP6nQ",
"amount": 1000,
"charges": 1000,
"status": "APPROVED",
"type": "DEBIT",
"merchant_name": "Google Inc",
"merchant_city": "",
"merchant_country": "",
"merchant_postal_code": "",
"merchant_state": "",
"merchant_mcc": "",
"merchant_mid": "",
"currency": "USD",
"category": "FUNDING",
"created_at": "2024-02-06T02:49:18Z",
"updated_at": "2024-02-06T02:49:18Z"
}
}
```
## Charges webhook event
The `card.charges` event is fired when a card-related fee is debited from the business USD wallet. It is not emitted when the fee is successfully taken directly from the card.
Use `charge_type` to identify the fee:
* `CARD_DECLINE_FEE`: a declined-card fee that could not be collected from the card.
* `CROSS_BORDER_FEE`: a pending cross-border fee passed to the business wallet.
`funding_source` is `BUSINESS_WALLET` for this event.
```json card.charges theme={null}
{
"event": "card.charges",
"id": "evt_123456789",
"data": {
"id": "txn_123456789",
"reference": "ref_mviuNSMKi74vTY8yvfP6nQ",
"amount": 0.3,
"charges": 0,
"fiat_rate": 0,
"detail": "Card transaction charges",
"category": "CARD",
"type": "DEBIT",
"status": "COMPLETED",
"created_at": "2026-07-20T15:30:00Z",
"updated_at": "2026-07-20T15:30:00Z",
"card": {
"id": "card_123456789",
"business_id": "bus_mviuNSMKi74vTY8yvfP6nQ",
"status": "ACTIVE",
"balance": 10,
"created_at": "2026-07-01T09:00:00Z",
"updated_at": "2026-07-20T15:30:00Z"
},
"charge_type": "CARD_DECLINE_FEE",
"funding_source": "BUSINESS_WALLET"
}
}
```
## Contactless activation webhook event
The `card.contactless.activation` event contains the one-time code needed to add a contactless card to a supported wallet. This confidential event is delivered only after the business [explicitly subscribes an eligible webhook](/webhooks/introduction#contactless-activation-subscriptions).
```json card.contactless.activation theme={null}
{
"event": "card.contactless.activation",
"id": "3ca42ad1-1eb9-4ee7-828b-e00fbd2234c0",
"data": {
"customer_id": "cus_123456789",
"email": "customer@example.com",
"activation_code": "328893"
}
}
```
Swervpay includes these headers:
| Header | Description |
| ------------------- | ------------------------------------------ |
| `X-SWERV-Event` | `card.contactless.activation` |
| `X-SWERV-Event-Id` | Stable identifier for the activation event |
| `X-SWERV-Timestamp` | Unix timestamp used to sign the request |
| `X-SWERV-Signature` | `t=,v1=` |
Verify the signature against the raw request body using the webhook signing key returned when the webhook was created. The signed message is:
```text theme={null}
.
```
```js NodeJS theme={null}
import crypto from "node:crypto";
function verifyContactlessActivation(rawBody, headers, signingKey) {
const timestamp = headers["x-swerv-timestamp"];
const supplied = headers["x-swerv-signature"];
const message = `${timestamp}.${rawBody}`;
const digest = crypto
.createHmac("sha256", signingKey)
.update(message)
.digest("hex");
const expected = `t=${timestamp},v1=${digest}`;
const expectedBuffer = Buffer.from(expected);
const suppliedBuffer = Buffer.from(supplied || "");
return expectedBuffer.length === suppliedBuffer.length &&
crypto.timingSafeEqual(expectedBuffer, suppliedBuffer);
}
```
Validate that the timestamp is recent, verify the signature before parsing the body, store the event ID for idempotency, and return `2xx` promptly. Swervpay attempts confidential delivery up to three times. Activation payloads are redacted from webhook logs and cannot be manually retried through the webhook retry endpoint.
# Collection
Source: https://docs.swervpay.co/webhooks/collection
Overview of Collection Webhook Events
## Overview
Our collection webhook events are fired based on the following triggers:
* Completed webhook event
* Collection created event
* Collection created failed event
For USD collection accounts, `collection.created` confirms that the customer's USD account has been issued and contains the final account details. `collection.created.failed` is sent when the account request is rejected or cannot be completed.
## Completed webhook event
```json collection.completed theme={null}
{
"event": "collection.completed",
"data": {
"id": "txn_zRo4J1WQU6bvvh2umYwA",
"reference": "ref_zWkNkNFhbK3igZ8bDtEu",
"business_id": "bsn_fAYcWSUXz3TogChv7BgH",
"status": "COMPLETED",
"amount": 500000,
"charges": 1000,
"type": "CREDIT",
"detail": "Fund wallet",
"created_at": "2024-03-13T21:00:28Z",
"updated_at": "2024-03-13T21:00:28Z"
}
}
```
## Collection created event
```json collection.created theme={null}
{
"event": "collection.created",
"data": {
"wallet_id": "string",
"business_id": "string",
"account_number": "string",
"bank_code": "string",
"bank_name": "string",
"account_name": "string",
"routing_number": "string",
"account_type": "string",
"bank_address": "string",
}
}
```
## Collection created failed event
```json collection.created.failed theme={null}
{
"event": "collection.created.failed",
"data": {
"collection": {
"wallet_id": "string",
"business_id": "string",
"account_number": "string",
"bank_code": "string",
"bank_name": "string",
"account_name": "string",
"routing_number": "string",
"account_type": "string",
"bank_address": "string",
},
"reasons": [
{
"reason": "Invalid tax number"
}
]
}
}
```
# Customer
Source: https://docs.swervpay.co/webhooks/customer
Overview of Customer Webhook Events
## Overview
Our customer webhook events are fired based on the following triggers:
* Created webhook event
* Updated webhook event
* KYC webhook event
## Created webhook event
This event is fired when a customer is created.
```json customer.created theme={null}
{
"event": "customer.created",
"data": {
"business_id": "bus_mviuNSMKi74vTY8yvfP6nQ",
"id": "cus_BJ8ptMSAcm3n6qp6bFpc"
}
}
```
## Updated webhook event
This event is fired when a customer is updated.
```json customer.updated theme={null}
{
"event": "customer.updated",
"data": {
"business_id": "bus_mviuNSMKi74vTY8yvfP6nQ",
"id": "cus_BJ8ptMSAcm3n6qp6bFpc"
}
}
```
## KYC webhook event
This event is fired when a customer's KYC status is updated.
```json customer.kyc.updated theme={null}
{
"event": "customer.kyc.updated",
"data": {
"business_id": "bus_mviuNSMKi74vTY8yvfP6nQ",
"id": "cus_BJ8ptMSAcm3n6qp6bFpc",
"tier": "ONE",
"kyc_status": "APPROVED"
}
}
```
# Introduction
Source: https://docs.swervpay.co/webhooks/introduction
Introduction to Webhooks
## Introduction
Webhooks are a way for Swervpay to provide real-time data to your application. They are HTTP callbacks that receive notification messages for events. When an event occurs, Swervpay sends an HTTP POST request to the webhook's configured URL. Your endpoint should respond with a `2xx` status code to indicate that the event has been successfully received.
## Creating a Webhook
You can create a webhook from the [dashboard](https://app.swervpay.co/-/developers/webhooks).
## Contactless activation subscriptions
Contactless activation codes are confidential and are not sent to a webhook by default. To receive them, explicitly subscribe one enabled HTTPS webhook to `card.contactless.activation`.
Create a subscribed webhook:
```bash theme={null}
curl --request POST \
--url https://api.swervpay.co/api/v1/webhook \
--header 'Authorization: Bearer ' \
--header 'Content-Type: application/json' \
--data '{
"url": "https://example.com/webhooks/swervpay",
"description": "Contactless activation webhook",
"events": ["card.contactless.activation"]
}'
```
Or update an existing webhook:
```bash theme={null}
curl --request PUT \
--url https://api.swervpay.co/api/v1/webhook/ \
--header 'Authorization: Bearer ' \
--header 'Content-Type: application/json' \
--data '{
"url": "https://example.com/webhooks/swervpay",
"description": "Contactless activation webhook",
"events": ["card.contactless.activation"]
}'
```
The endpoint must:
* Use HTTPS.
* Return a `2xx` response.
* Be the only enabled webhook subscribed to `card.contactless.activation` for the business.
When no unique eligible subscription can be resolved, or delivery fails, Swervpay sends the activation code using the standard Swervpay email instead.
Supplying `events` when editing replaces the webhook's stored event list. Include every event that should remain explicitly registered. Omitting `events` preserves the existing list.
## Authentication
All webhook requests include a `X-SWERV-SECRET` header for verification. It should match the secret generated when creating the webhook.
The confidential `card.contactless.activation` event uses an HMAC signature instead of `X-SWERV-SECRET`. See the [card webhook documentation](/webhooks/card#contactless-activation-webhook-event) for its headers and verification procedure.
```js NodeJS theme={null}
const secret = process.env.SWERVPAY_SECRET;
function verifyWebhook(req, res, next) {
if (req.headers['X-SWERV-SECRET'] !== secret) {
return res.status(401).json({
message: "Unauthorized request."
});
}
next();
}
router.post('/webhook', verifyWebhook, (req, res) => {
const webhook = req.body;
switch(webhook.event) {
case "card.created":
break;
}
return res.sendStatus(200);
});
```
```php PHP theme={null}
$secret = getenv('SWERVPAY_SECRET');
function verifyWebhook($secret) {
$header = $_SERVER['HTTP_SWERVPAY_SECRET'];
if ($header !== $secret) {
http_response_code(401);
echo 'Unauthorized request';
exit();
}
}
function handleWebhook() {
$json = file_get_contents('php://input');
$data = json_decode($json, true);
if (json_last_error() !== JSON_ERROR_NONE) {
http_response_code(400);
echo 'Invalid JSON body';
exit();
}
switch ($data['event']) {
case 'card.created':
// Handle the event
break;
}
http_response_code(200);
}
verifyWebhook($secret);
handleWebhook();
```
```php Laravel theme={null}
// In your middleware
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
class VerifyWebhook
{
public function handle(Request $request, Closure $next)
{
$secret = env('SWERVPAY_SECRET');
if ($request->header('X-SWERV-SECRET') !== $secret) {
return response('Unauthorized request', 401);
}
return $next($request);
}
}
// In your controller
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class WebhookController extends Controller
{
public function handle(Request $request)
{
$data = $request->json()->all();
switch ($data['event']) {
case 'card.created':
// Handle the event
break;
}
return response(null, 200);
}
}
// In your routes/web.php or routes/api.php
Route::post('/webhook', 'App\Http\Controllers\WebhookController@handle')->middleware('App\Http\Middleware\VerifyWebhook');
```
```go Go theme={null}
package main
import (
"encoding/json"
"net/http"
"os"
"github.com/gorilla/mux"
)
var secret = os.Getenv("SWERVPAY_SECRET")
func verifyWebhook(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Header.Get("X-SWERV-SECRET") != secret {
http.Error(w, "Unauthorized request", http.StatusUnauthorized)
return
}
next.ServeHTTP(w, r)
})
}
type Webhook struct {
Event string `json:"event"`
}
func handleWebhook(w http.ResponseWriter, r *http.Request) {
var webhook Webhook
err := json.NewDecoder(r.Body).Decode(&webhook)
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
switch webhook.Event {
case "card.created":
// Handle the event
}
w.WriteHeader(http.StatusOK)
}
func main() {
r := mux.NewRouter()
r.Use(verifyWebhook)
r.HandleFunc("/webhook", handleWebhook).Methods("POST")
http.ListenAndServe(":8080", r)
}
```
## Retry
If a webhook fails, you have two main options to retry the failed delivery:
* Retry from developer section of the [dashboard](https://app.swervpay.co/-/developers/webhooks)
* Using [webhook Retry API](/api-reference/webhook/retry)
# Payout
Source: https://docs.swervpay.co/webhooks/payout
Overview of Payout Webhook Events
## Overview
Our payout webhook events are fired based on the following triggers:
* Completed webhook event
* Failed webhook event
## Completed webhook event
This event is fired when a payout is completed.
```json payout.completed theme={null}
{
"event": "payout.completed",
"data": {
"id": "txn_LKkX3akrzdpJpfA2WGc5",
"reference": "ref_ZwfWk6AfTb42GTibd4yG",
"business_id": "bsn_fAYcWSUXz3TogChv7BgH",
"status": "COMPLETED",
"amount": 500000,
"charges": 20,
"type": "DEBIT",
"detail": "God help us",
"created_at": "2024-03-12T15:09:24Z",
"updated_at": "2024-03-12T14:24:07Z"
}
}
```
## Failed webhook event
This event is fired when a payout is failed.
```json payout.failed theme={null}
{
"event": "payout.failed",
"data": {
"id": "txn_LKkX3akrzdpJpfA2WGc5",
"reference": "ref_ZwfWk6AfTb42GTibd4yG",
"business_id": "bsn_fAYcWSUXz3TogChv7BgH",
"status": "FAILED",
"amount": 500000,
"charges": 20,
"type": "DEBIT",
"detail": "God help us",
"created_at": "2024-03-12T15:09:24Z",
"updated_at": "2024-03-12T14:24:07Z"
}
}
```
# Wallet
Source: https://docs.swervpay.co/webhooks/wallet
Overview of Wallet Webhook Events
## Overview
Our wallet webhook events are fired based on the following triggers:
* Updated webhook event
## Updated webhook event
This event is fired when a wallet is updated.
```json wallet.updated theme={null}
{
"event": "wallet.updated",
"data": {
"wallet_id": "wlt_Za3WgMTHsD5NSYMeqRJ7",
"business_id": "bsn_fAYcWSUXz3TogChv7BgH",
"type": "CREDIT",
"amount": 11000,
"balance": 402850
}
}
```