Quick start
- Create a SahiAPI account and complete verification.
- Open API Tokens in the client panel. Copy your active API key.
- Send the test request below from your server. Test mode returns sample data, not a live GST record.
- Buy credits and change
modetolivewhen ready.
Base URL: https://sahiapi.com/api/v1. Use HTTPS in production.
Authentication
Send your client API key in the X-API-Key request header. A dashboard session or an API key in the JSON body does not authenticate this endpoint. Keep keys on your server, outside public source code and browser JavaScript.
X-API-Key: YOUR_API_KEY
Content-Type: application/json
Accept: application/json
Only the active key for your account works. Regenerating, disabling or expiring a key prevents further access. Update your integration after regeneration. Never paste a real key into a support message.
Verify a GST number
POST /api/v1/client/gst
| JSON field | Required | Accepted value |
|---|---|---|
gstNo | Yes | 15 uppercase letters/digits, beginning with a two-digit state code. |
mode | Yes | test or live. |
testMode | When mode is test | active or inactive. Currently required by validation; it does not change the mock response. |
Test request
Import the JSON collection in Postman, or extract the ZIP and open the SahiAPI folder in Bruno. Both include test and live requests. Set base_url for your deployment and supply your local api_key; no key is included. In Bruno, select the SahiAPI environment and set the API-key secret. Start with the test request. Live requests use paid credits. Never commit or share your key.
Set the SAHIAPI_KEY environment variable on your server to your active key, then choose your language below. No SahiAPI SDK is required. Each example prints the HTTP status and response body; check both before treating a verification as successful. The cURL command uses POSIX shell syntax; on Windows, run it in WSL or Git Bash.
# POSIX shell. Set SAHIAPI_KEY to your active API key first.
curl --request POST 'https://sahiapi.com/api/v1/client/gst' \
--max-time 30 --include \
--header "X-API-Key: ${SAHIAPI_KEY:?Set SAHIAPI_KEY first}" \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data '{
"gstNo": "29CGTPB7711E1Z9",
"mode": "test",
"testMode": "active"
}'
<?php
// PHP 8+ with the cURL extension.
$apiKey = getenv('SAHIAPI_KEY') ?: throw new RuntimeException('Set SAHIAPI_KEY first.');
$curl = curl_init('https://sahiapi.com/api/v1/client/gst');
curl_setopt_array($curl, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTPHEADER => [
'X-API-Key: '.$apiKey,
'Content-Type: application/json',
'Accept: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'gstNo' => '29CGTPB7711E1Z9',
'mode' => 'test',
'testMode' => 'active',
], JSON_THROW_ON_ERROR),
]);
$body = curl_exec($curl);
if ($body === false) {
throw new RuntimeException(curl_error($curl));
}
echo 'HTTP '.curl_getinfo($curl, CURLINFO_HTTP_CODE).PHP_EOL;
echo $body.PHP_EOL;
curl_close($curl);
# Python 3; standard library only.
import json
import os
from urllib.error import HTTPError
from urllib.request import Request, urlopen
request = Request(
"https://sahiapi.com/api/v1/client/gst",
method="POST",
headers={
"X-API-Key": os.environ["SAHIAPI_KEY"],
"Content-Type": "application/json",
"Accept": "application/json",
},
data=json.dumps({
"gstNo": "29CGTPB7711E1Z9",
"mode": "test",
"testMode": "active",
}).encode("utf-8"),
)
try:
with urlopen(request, timeout=30) as response:
print("HTTP", response.status)
print(response.read().decode("utf-8"))
except HTTPError as error:
print("HTTP", error.code)
print(error.read().decode("utf-8"))
# Ruby with the standard net/http and json libraries.
require 'net/http'
require 'json'
uri = URI('https://sahiapi.com/api/v1/client/gst')
request = Net::HTTP::Post.new(uri)
request['X-API-Key'] = ENV.fetch('SAHIAPI_KEY')
request['Content-Type'] = 'application/json'
request['Accept'] = 'application/json'
request.body = JSON.generate({
gstNo: '29CGTPB7711E1Z9',
mode: 'test',
testMode: 'active'
})
response = Net::HTTP.start(uri.hostname, uri.port,
use_ssl: uri.scheme == 'https', open_timeout: 10, read_timeout: 30) do |http|
http.request(request)
end
puts "HTTP #{response.code}"
puts response.body
// C# / .NET 6+ console app; standard libraries only.
using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;
var apiKey = Environment.GetEnvironmentVariable("SAHIAPI_KEY")
?? throw new InvalidOperationException("Set SAHIAPI_KEY first.");
using var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };
using var request = new HttpRequestMessage(HttpMethod.Post, "https://sahiapi.com/api/v1/client/gst");
request.Headers.Add("X-API-Key", apiKey);
request.Headers.Add("Accept", "application/json");
request.Content = new StringContent(JsonSerializer.Serialize(new {
gstNo = "29CGTPB7711E1Z9",
mode = "test",
testMode = "active"
}), Encoding.UTF8, "application/json");
using var response = await client.SendAsync(request);
Console.WriteLine($"HTTP {(int)response.StatusCode}");
Console.WriteLine(await response.Content.ReadAsStringAsync());
// Java 11+. Save as SahiApiExample.java.
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
public class SahiApiExample {
public static void main(String[] args) throws Exception {
String apiKey = System.getenv("SAHIAPI_KEY");
if (apiKey == null || apiKey.isBlank()) {
throw new IllegalStateException("Set SAHIAPI_KEY first.");
}
HttpClient client = HttpClient.newBuilder()
.connectTimeout(Duration.ofSeconds(10)).build();
String json = "{\"gstNo\":\"29CGTPB7711E1Z9\","
+ "\"mode\":\"test\",\"testMode\":\"active\"}";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://sahiapi.com/api/v1/client/gst"))
.timeout(Duration.ofSeconds(30))
.header("X-API-Key", apiKey)
.header("Content-Type", "application/json")
.header("Accept", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(json)).build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println("HTTP " + response.statusCode());
System.out.println(response.body());
}
}
// Node.js 18+; built-in fetch. Run this on your server.
async function main() {
const apiKey = process.env.SAHIAPI_KEY;
if (!apiKey) throw new Error('Set SAHIAPI_KEY first.');
const response = await fetch('https://sahiapi.com/api/v1/client/gst', {
method: 'POST',
signal: AbortSignal.timeout(30_000),
headers: {
'X-API-Key': apiKey,
'Content-Type': 'application/json',
'Accept': 'application/json',
},
body: JSON.stringify({
gstNo: '29CGTPB7711E1Z9',
mode: 'test',
testMode: 'active',
}),
});
console.log('HTTP', response.status);
console.log(await response.text());
}
main().catch((error) => {
console.error(error.message);
process.exitCode = 1;
});
// C++11+ with libcurl development headers/libraries installed.
// Save as sahiapi.cpp; compile: c++ sahiapi.cpp -o sahiapi -lcurl
#include <curl/curl.h>
#include <cstdlib>
#include <initializer_list>
#include <iostream>
#include <string>
int main() {
const char* apiKey = std::getenv("SAHIAPI_KEY");
if (!apiKey || !*apiKey) {
std::cerr << "Set SAHIAPI_KEY first.\n";
return 1;
}
if (curl_global_init(CURL_GLOBAL_DEFAULT) != CURLE_OK) return 1;
CURL* client = curl_easy_init();
if (!client) { curl_global_cleanup(); return 1; }
curl_slist* headers = nullptr;
for (const std::string& header : {
std::string("X-API-Key: ") + apiKey,
std::string("Content-Type: application/json"),
std::string("Accept: application/json")
}) {
curl_slist* next = curl_slist_append(headers, header.c_str());
if (!next) {
curl_slist_free_all(headers);
curl_easy_cleanup(client);
curl_global_cleanup();
return 1;
}
headers = next;
}
curl_easy_setopt(client, CURLOPT_URL, "https://sahiapi.com/api/v1/client/gst");
curl_easy_setopt(client, CURLOPT_POST, 1L);
curl_easy_setopt(client, CURLOPT_TIMEOUT, 30L);
curl_easy_setopt(client, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(client, CURLOPT_POSTFIELDS,
"{\"gstNo\":\"29CGTPB7711E1Z9\",\"mode\":\"test\",\"testMode\":\"active\"}");
// Print HTTP status/headers followed by the response body, including errors.
curl_easy_setopt(client, CURLOPT_HEADER, 1L);
CURLcode result = curl_easy_perform(client);
if (result != CURLE_OK) std::cerr << curl_easy_strerror(result) << '\n';
curl_slist_free_all(headers);
curl_easy_cleanup(client);
curl_global_cleanup();
return result == CURLE_OK ? 0 : 1;
}
// In a Cargo binary project: cargo add reqwest@0.13 --features blocking
// Save as src/main.rs; run: cargo run
use std::{env, error::Error, time::Duration};
fn main() -> Result<(), Box<dyn Error>> {
let api_key = env::var("SAHIAPI_KEY")?;
if api_key.is_empty() {
return Err("Set SAHIAPI_KEY first.".into());
}
let client = reqwest::blocking::Client::builder()
.timeout(Duration::from_secs(30))
.redirect(reqwest::redirect::Policy::none())
.build()?;
let response = client.post("https://sahiapi.com/api/v1/client/gst")
.header("X-API-Key", api_key)
.header("Content-Type", "application/json")
.header("Accept", "application/json")
.body("{\"gstNo\":\"29CGTPB7711E1Z9\",\"mode\":\"test\",\"testMode\":\"active\"}")
.send()?;
println!("HTTP {}", response.status().as_u16());
println!("{}", response.text()?);
Ok(())
}
// Go; standard library only. Save as main.go; run: go run main.go
package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
"time"
)
func run() error {
apiKey := os.Getenv("SAHIAPI_KEY")
if apiKey == "" {
return fmt.Errorf("set SAHIAPI_KEY first")
}
body := strings.NewReader(`{"gstNo":"29CGTPB7711E1Z9","mode":"test","testMode":"active"}`)
request, err := http.NewRequest(http.MethodPost, "https://sahiapi.com/api/v1/client/gst", body)
if err != nil { return err }
request.Header.Set("X-API-Key", apiKey)
request.Header.Set("Content-Type", "application/json")
request.Header.Set("Accept", "application/json")
client := &http.Client{
Timeout: 30 * time.Second,
CheckRedirect: func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse
},
}
response, err := client.Do(request)
if err != nil { return err }
defer response.Body.Close()
data, err := io.ReadAll(response.Body)
if err != nil { return err }
fmt.Printf("HTTP %d\n%s\n", response.StatusCode, data)
return nil
}
func main() {
if err := run(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
HTTP client references: cURL, PHP, Python, Ruby, .NET, Java, Node.js, C++ / libcurl, Rust / reqwest, Go.
Live request body
{
"gstNo": "29CGTPB7711E1Z9",
"mode": "live"
}
Live mode uses your paid credit balance and contacts a configured verification provider. Test credits cannot pay for live requests.
Read the response
The following is an excerpt from the current test response. Mock values are illustrative. Live response fields depend on the active provider; do not assume the mock structure is guaranteed for every provider.
{
"data": {
"gstin": "29CGTPB7711E1Z9",
"lgnm": "Mock Business Name 29CGT",
"tradeNam": "Mock Trade Name",
"sts": "Active",
"dty": "Regular",
"einvoiceStatus": "No",
"panNo": "CGTPB7711E"
},
"status_cd": "1",
"status_desc": "Public API Search Taxpayer Success"
}
Check both HTTP status and the response body. Some business failures currently return HTTP 200 with status: false, for example insufficient credits. Provider responses may contain their own status fields. Treat a failed response as a failed verification, even when the HTTP request succeeds.
{
"status": false,
"message": "Insufficient live credits. Please purchase credits.",
"data": []
}
Errors and rate limits
| HTTP status | Meaning | What to do |
|---|---|---|
| 200 with failure body | Insufficient credits, unavailable wallet, or verification/provider failure. | Inspect the message and account balance. Avoid blind retries. |
| 401 | Missing, invalid, expired or disabled API key. | Check your active X-API-Key. |
| 403 | Account is not active. | Contact support. |
| 422 | Request validation failed. | Read errors and correct the fields. |
| 429 | Request rate limit reached. | Wait before retrying; respect any Retry-After header. |
| 500 | Unexpected application failure. | Retry cautiously and contact support if it continues. |
GST verification currently allows 10 requests per minute per API token. Other client API routes have a separate limit of 60 requests per minute. These are request limits, not guaranteed processing-time or uptime commitments.
Credits and billing
New registrations receive 50 Free test credits. Each processed test verification uses one test credit. Live verification uses one paid credit. Provider calls that return a response can be chargeable even when the result is not a successful GST validation. A provider exception before a response does not deduct a credit.
Complete your profile with Name, Email, Mobile, GST Number and PAN before buying credits.
Recharge by amount or credit quantity in the client panel. The applicable whole-purchase pricing slab, minimum recharge, GST and total appear before payment. Amount entry charges the full entered amount and rounds down to whole credits. Credit entry prices your exact quantity. Rates for an existing order remain fixed at order creation.
Non-refundable and non-cancellable service. Credit purchases are non-refundable and non-cancellable, and unused credits cannot be exchanged for cash, except where applicable law requires otherwise. Read the Refund & Cancellation Policy and Terms & Conditions before purchasing.
Invoices are generated automatically after payment confirmation and for paid manual top-ups. Download available invoices from your orders page.
Usage and support
Use API Usage to review request time, mode, GST number, response details and credits deducted. View balances in your wallet and configure low-credit alerts. For account or integration issues, open a support ticket or email contact@sahiapi.com.
Related policies: Privacy Policy and Terms & Conditions.