Samva
Samva
DashboardAPISamva DocumentationQuickstart GuideAuthentication

SDKs & ToolsTypeScript SDKREST APIPostman Collection
SDKs & Tools

REST API

Direct REST API integration guide for Samva

Integrate directly with Samva's REST API using any HTTP client or programming language.

Base URL

https://samva.app/api/v1

Authentication

All API requests require authentication via the X-API-Key header:

curl -H "X-API-Key: sk_live_your_api_key" \
  https://samva.app/api/v1/messages

Content Type

All requests should include the Content-Type: application/json header for POST/PUT/PATCH requests.

Examples

Send Email

curl -X POST https://samva.app/api/v1/email/send \
  -H "X-API-Key: sk_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "user@example.com",
    "subject": "Welcome to Samva",
    "htmlContent": "<h1>Hello!</h1><p>Welcome to our platform.</p>",
    "textContent": "Hello! Welcome to our platform."
  }'

Response:

{
  "id": "msg_abc123def456",
  "status": "pending"
}

Send SMS

curl -X POST https://samva.app/api/v1/sms/send \
  -H "X-API-Key: sk_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "+14155552671",
    "message": "Your verification code is 123456"
  }'

Send WhatsApp Message

curl -X POST https://samva.app/api/v1/whatsapp/send \
  -H "X-API-Key: sk_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "+14155552671",
    "message": "Hello from Samva!"
  }'

List Messages

curl https://samva.app/api/v1/messages \
  -H "X-API-Key: sk_live_your_api_key"

Get Message by ID

curl https://samva.app/api/v1/messages/msg_abc123def456 \
  -H "X-API-Key: sk_live_your_api_key"

Response Format

All responses follow a consistent JSON format:

Success Response

{
  "id": "msg_abc123def456",
  "status": "pending",
  "channel": "email",
  "createdAt": "2024-01-15T10:30:00.000Z"
}

Error Response

{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Invalid email address format",
    "details": {
      "field": "to",
      "reason": "Must be a valid email address"
    }
  }
}

HTTP Status Codes

CodeDescription
200Success
201Created
400Bad Request - Invalid parameters
401Unauthorized - Invalid or missing API key
403Forbidden - Insufficient permissions
404Not Found - Resource doesn't exist
429Too Many Requests - Rate limit exceeded
500Internal Server Error

Rate Limiting

API requests are rate-limited based on your plan. Rate limit information is included in response headers:

X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1640995200

Pagination

List endpoints support pagination via query parameters:

curl "https://samva.app/api/v1/messages?page=1&limit=20" \
  -H "X-API-Key: sk_live_your_api_key"

Response includes pagination metadata:

{
  "items": [...],
  "pagination": {
    "page": 1,
    "limit": 20,
    "total": 150,
    "totalPages": 8
  }
}

Language Examples

Python (requests)

import requests

headers = {
    'X-API-Key': 'sk_live_your_api_key',
    'Content-Type': 'application/json'
}

response = requests.post(
    'https://samva.app/api/v1/email/send',
    headers=headers,
    json={
        'to': 'user@example.com',
        'subject': 'Hello',
        'textContent': 'Welcome to Samva!'
    }
)

print(response.json())

Go (net/http)

package main

import (
    "bytes"
    "encoding/json"
    "net/http"
)

func main() {
    payload := map[string]string{
        "to":          "user@example.com",
        "subject":     "Hello",
        "textContent": "Welcome to Samva!",
    }

    body, _ := json.Marshal(payload)

    req, _ := http.NewRequest("POST",
        "https://samva.app/api/v1/email/send",
        bytes.NewBuffer(body))

    req.Header.Set("X-API-Key", "sk_live_your_api_key")
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, _ := client.Do(req)
    defer resp.Body.Close()
}

PHP (cURL)

<?php
$ch = curl_init();

curl_setopt_array($ch, [
    CURLOPT_URL => 'https://samva.app/api/v1/email/send',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_HTTPHEADER => [
        'X-API-Key: sk_live_your_api_key',
        'Content-Type: application/json'
    ],
    CURLOPT_POSTFIELDS => json_encode([
        'to' => 'user@example.com',
        'subject' => 'Hello',
        'textContent' => 'Welcome to Samva!'
    ])
]);

$response = curl_exec($ch);
curl_close($ch);

print_r(json_decode($response, true));

Next Steps

API Reference

Complete endpoint documentation

TypeScript SDK

Use our official SDK

Authentication

API key management

Postman Collection

Import our collection

TypeScript SDK

Official TypeScript/JavaScript SDK for Samva API

Postman Collection

Import Samva API collection into Postman

On this page

Base URLAuthenticationContent TypeExamplesSend EmailSend SMSSend WhatsApp MessageList MessagesGet Message by IDResponse FormatSuccess ResponseError ResponseHTTP Status CodesRate LimitingPaginationLanguage ExamplesPython (requests)Go (net/http)PHP (cURL)Next Steps