> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.senjaropay.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.senjaropay.com/_mcp/server.

# Create mobile payment request

POST https://api.senjaropay.com/senjaropay/merchant/payments/create
Content-Type: application/json

Creates a USSD push request for customer payment authorization.

Reference: https://docs.senjaropay.com/api-documentation/collections/create-payment

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: SenjaroPay API
  version: 1.0.0
paths:
  /senjaropay/merchant/payments/create:
    post:
      operationId: createPayment
      summary: Create mobile payment request
      description: Creates a USSD push request for customer payment authorization.
      tags:
        - subpackage_collections
      parameters:
        - name: x-api-key
          in: header
          required: true
          schema:
            type: string
        - name: x-idempotency-key
          in: header
          description: Unique key per transaction to avoid duplicate creates on retries.
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Payment request accepted
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreatePaymentResponse'
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreatePaymentRequest'
servers:
  - url: https://api.senjaropay.com
    description: SenjaroPay API
components:
  schemas:
    CreatePaymentRequestPaymentType:
      type: string
      enum:
        - mobile
      title: CreatePaymentRequestPaymentType
    PaymentDetails:
      type: object
      properties:
        amount:
          type: integer
        currency:
          type: string
      required:
        - amount
        - currency
      title: PaymentDetails
    PaymentCustomer:
      type: object
      properties:
        firstname:
          type: string
        lastname:
          type: string
        email:
          type:
            - string
            - 'null'
          format: email
        country:
          type:
            - string
            - 'null'
        city:
          type:
            - string
            - 'null'
        address:
          type:
            - string
            - 'null'
      required:
        - firstname
        - lastname
      title: PaymentCustomer
    CreatePaymentRequest:
      type: object
      properties:
        payment_type:
          $ref: '#/components/schemas/CreatePaymentRequestPaymentType'
        details:
          $ref: '#/components/schemas/PaymentDetails'
        phone_number:
          type: string
          description: MSISDN in international format
        customer:
          $ref: '#/components/schemas/PaymentCustomer'
        webhook_url:
          type: string
          format: uri
      required:
        - payment_type
        - details
        - phone_number
        - customer
      title: CreatePaymentRequest
    CreatePaymentResponseDataAmount:
      type: object
      properties:
        currency:
          type: string
        value:
          type: integer
      title: CreatePaymentResponseDataAmount
    CreatePaymentResponseData:
      type: object
      properties:
        amount:
          $ref: '#/components/schemas/CreatePaymentResponseDataAmount'
        api_version:
          type: string
        expires_at:
          type: string
          format: date-time
        object:
          type: string
        payment_type:
          type: string
        reference:
          type: string
        status:
          type: string
      title: CreatePaymentResponseData
    CreatePaymentResponse:
      type: object
      properties:
        status:
          type: string
        code:
          type: integer
        data:
          $ref: '#/components/schemas/CreatePaymentResponseData'
      required:
        - status
        - code
        - data
      title: CreatePaymentResponse
    ApiError:
      type: object
      properties:
        status:
          type: string
        code:
          type: integer
        error_code:
          type: string
        message:
          type: string
      title: ApiError
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
    apiSecretAuth:
      type: apiKey
      in: header
      name: x-api-secret

```

## Examples



**Request**

```json
{
  "payment_type": "mobile",
  "details": {
    "amount": 1000,
    "currency": "TZS"
  },
  "phone_number": "255700000001",
  "customer": {
    "firstname": "Test",
    "lastname": "Customer",
    "email": "test.customer@example.com",
    "country": "Tanzania",
    "city": "Dar es Salaam",
    "address": "Sample Street"
  },
  "webhook_url": "https://example.com/webhooks/senjaropay/mock-callback"
}
```

**Response**

```json
{
  "status": "success",
  "code": 200,
  "data": {
    "amount": {
      "currency": "TZS",
      "value": 1000
    },
    "api_version": "2026-01-25",
    "expires_at": "2026-04-17T09:13:54.946Z",
    "object": "payment",
    "payment_type": "mobile",
    "reference": "mock-ref-7b2a4f3e",
    "status": "pending"
  }
}
```

**SDK Code**

```python collections_createPayment_example
import requests

url = "https://api.senjaropay.com/senjaropay/merchant/payments/create"

payload = {
    "payment_type": "mobile",
    "details": {
        "amount": 1000,
        "currency": "TZS"
    },
    "phone_number": "255700000001",
    "customer": {
        "firstname": "Test",
        "lastname": "Customer",
        "email": "test.customer@example.com",
        "country": "Tanzania",
        "city": "Dar es Salaam",
        "address": "Sample Street"
    },
    "webhook_url": "https://example.com/webhooks/senjaropay/mock-callback"
}
headers = {
    "x-idempotency-key": "x-idempotency-key",
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript collections_createPayment_example
const url = 'https://api.senjaropay.com/senjaropay/merchant/payments/create';
const options = {
  method: 'POST',
  headers: {
    'x-idempotency-key': 'x-idempotency-key',
    'x-api-key': '<apiKey>',
    'Content-Type': 'application/json'
  },
  body: '{"payment_type":"mobile","details":{"amount":1000,"currency":"TZS"},"phone_number":"255700000001","customer":{"firstname":"Test","lastname":"Customer","email":"test.customer@example.com","country":"Tanzania","city":"Dar es Salaam","address":"Sample Street"},"webhook_url":"https://example.com/webhooks/senjaropay/mock-callback"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go collections_createPayment_example
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.senjaropay.com/senjaropay/merchant/payments/create"

	payload := strings.NewReader("{\n  \"payment_type\": \"mobile\",\n  \"details\": {\n    \"amount\": 1000,\n    \"currency\": \"TZS\"\n  },\n  \"phone_number\": \"255700000001\",\n  \"customer\": {\n    \"firstname\": \"Test\",\n    \"lastname\": \"Customer\",\n    \"email\": \"test.customer@example.com\",\n    \"country\": \"Tanzania\",\n    \"city\": \"Dar es Salaam\",\n    \"address\": \"Sample Street\"\n  },\n  \"webhook_url\": \"https://example.com/webhooks/senjaropay/mock-callback\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("x-idempotency-key", "x-idempotency-key")
	req.Header.Add("x-api-key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby collections_createPayment_example
require 'uri'
require 'net/http'

url = URI("https://api.senjaropay.com/senjaropay/merchant/payments/create")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-idempotency-key"] = 'x-idempotency-key'
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"payment_type\": \"mobile\",\n  \"details\": {\n    \"amount\": 1000,\n    \"currency\": \"TZS\"\n  },\n  \"phone_number\": \"255700000001\",\n  \"customer\": {\n    \"firstname\": \"Test\",\n    \"lastname\": \"Customer\",\n    \"email\": \"test.customer@example.com\",\n    \"country\": \"Tanzania\",\n    \"city\": \"Dar es Salaam\",\n    \"address\": \"Sample Street\"\n  },\n  \"webhook_url\": \"https://example.com/webhooks/senjaropay/mock-callback\"\n}"

response = http.request(request)
puts response.read_body
```

```java collections_createPayment_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.senjaropay.com/senjaropay/merchant/payments/create")
  .header("x-idempotency-key", "x-idempotency-key")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"payment_type\": \"mobile\",\n  \"details\": {\n    \"amount\": 1000,\n    \"currency\": \"TZS\"\n  },\n  \"phone_number\": \"255700000001\",\n  \"customer\": {\n    \"firstname\": \"Test\",\n    \"lastname\": \"Customer\",\n    \"email\": \"test.customer@example.com\",\n    \"country\": \"Tanzania\",\n    \"city\": \"Dar es Salaam\",\n    \"address\": \"Sample Street\"\n  },\n  \"webhook_url\": \"https://example.com/webhooks/senjaropay/mock-callback\"\n}")
  .asString();
```

```php collections_createPayment_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.senjaropay.com/senjaropay/merchant/payments/create', [
  'body' => '{
  "payment_type": "mobile",
  "details": {
    "amount": 1000,
    "currency": "TZS"
  },
  "phone_number": "255700000001",
  "customer": {
    "firstname": "Test",
    "lastname": "Customer",
    "email": "test.customer@example.com",
    "country": "Tanzania",
    "city": "Dar es Salaam",
    "address": "Sample Street"
  },
  "webhook_url": "https://example.com/webhooks/senjaropay/mock-callback"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
    'x-idempotency-key' => 'x-idempotency-key',
  ],
]);

echo $response->getBody();
```

```csharp collections_createPayment_example
using RestSharp;

var client = new RestClient("https://api.senjaropay.com/senjaropay/merchant/payments/create");
var request = new RestRequest(Method.POST);
request.AddHeader("x-idempotency-key", "x-idempotency-key");
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"payment_type\": \"mobile\",\n  \"details\": {\n    \"amount\": 1000,\n    \"currency\": \"TZS\"\n  },\n  \"phone_number\": \"255700000001\",\n  \"customer\": {\n    \"firstname\": \"Test\",\n    \"lastname\": \"Customer\",\n    \"email\": \"test.customer@example.com\",\n    \"country\": \"Tanzania\",\n    \"city\": \"Dar es Salaam\",\n    \"address\": \"Sample Street\"\n  },\n  \"webhook_url\": \"https://example.com/webhooks/senjaropay/mock-callback\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift collections_createPayment_example
import Foundation

let headers = [
  "x-idempotency-key": "x-idempotency-key",
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "payment_type": "mobile",
  "details": [
    "amount": 1000,
    "currency": "TZS"
  ],
  "phone_number": "255700000001",
  "customer": [
    "firstname": "Test",
    "lastname": "Customer",
    "email": "test.customer@example.com",
    "country": "Tanzania",
    "city": "Dar es Salaam",
    "address": "Sample Street"
  ],
  "webhook_url": "https://example.com/webhooks/senjaropay/mock-callback"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.senjaropay.com/senjaropay/merchant/payments/create")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```