Mobile API
React Native / Expo integration guide
A dedicated API layer for connecting React Native and Expo mobile apps to the TechSosten platform. Includes authentication, user management, device tracking, repairs, orders, support tickets, and more.
https://your-domain.com/api/mobileGetting Started
Integrate the TechSosten Mobile API into your React Native or Expo app in minutes.
1Copy the API client
Copy src/mobile-sdk/api-client.ts into your React Native project. It provides a fully typed, ready-to-use client.
import { TechSostenClient } from './api-client';
const api = new TechSostenClient('https://your-domain.com');2Install dependencies
The client uses the built-in fetch API — no external HTTP libraries needed. For secure token storage, install:
# Store auth tokens securely
npx expo install expo-secure-storeAuthentication
Login
| Method | Path | Description |
|---|---|---|
| POST | /auth/login | Authenticate with email and password |
Request Body
{
"email": "user@example.com",
"password": "your-password",
"deviceName": "iPhone 15",
"devicePlatform": "ios"
}Response
{
"success": true,
"data": {
"token": "<bearer-token>",
"expiresAt": "2026-09-13T12:00:00.000Z",
"user": {
"id": "...",
"email": "user@example.com",
"name": "John Doe",
"role": "user",
"userType": "individual",
"phone": "+2348000000000",
"emailVerified": true,
"plan": {
"id": "basic",
"name": "Basic"
},
"wallet": {
"balance": 150,
"currency": "USD"
}
}
}
}Register
| Method | Path | Description |
|---|---|---|
| POST | /auth/register | Create a new account |
Request Body
{
"email": "user@example.com",
"password": "secure-password",
"fullName": "John Doe",
"userType": "individual",
"phone": "+2348000000000",
"deviceName": "Expo Go",
"devicePlatform": "android"
}User Types
A 6-digit verification code is sent to the email address. Users must verify their email before accessing certain features. Registration automatically returns a bearer token (auto-login).
API Client (TypeScript)
The TechSostenClient class provides a fully typed interface to all mobile endpoints. Copy src/mobile-sdk/api-client.ts into your project.
Quick Start
import { TechSostenClient } from './api-client';
// Initialize the client
const api = new TechSostenClient('https://your-domain.com');
// 1. Login
const loginRes = await api.auth.login('user@example.com', 'password', 'iPhone 15', 'ios');
const { token, user } = loginRes.data;
// 2. Store and set the token
api.setToken(token);
// 3. Fetch dashboard data
const dashboard = await api.dashboard.get();
// 4. List devices
const devices = await api.devices.list({ page: 1, limit: 20, search: 'Samsung' });
// 5. Create a support ticket
const ticket = await api.tickets.create({
subject: 'Device not charging',
description: 'My phone stopped charging after the latest update.',
priority: 'high',
});Client API Reference
| Method | Description |
|---|---|
api.setToken(token) | Set the bearer token for subsequent requests |
api.getToken() | Get the current bearer token |
api.isAuthenticated() | Check if a token is set |
api.auth.login(email, password) | Authenticate and receive a token |
api.auth.register(data) | Create a new account |
api.profile.get() | Get current user profile |
api.profile.update(data) | Update profile fields |
api.dashboard.get() | Get dashboard summary stats |
api.devices.list(params) | List devices (paginated) |
api.devices.get(id) | Get device details |
api.clients.list(params) | List clients |
api.orders.list(params) | List orders |
api.repairs.list(params) | List repairs |
api.tickets.list(params) | List support tickets |
api.tickets.addMessage(id, msg) | Add a message to a ticket |
api.notifications.list(params) | List notifications |
api.notifications.markAsRead(id) | Mark a notification as read |
api.billing.get() | Get wallet & billing info |
Endpoints
All available mobile API endpoints, organized by resource.
Profile
| Method | Path | Description |
|---|---|---|
| GET | /profile | Get current user profile |
| PATCH | /profile | Update name, phone, language, or currency |
Dashboard
| Method | Path | Description |
|---|---|---|
| GET | /dashboard | Get summary stats (devices, clients, repairs, tickets, notifications, orders) |
Devices
| Method | Path | Description |
|---|---|---|
| GET | /devices | List devices (paginated, searchable) |
| GET | /devices/:id | Get device details |
| POST | /devices | Register a new device |
| PATCH | /devices/:id | Update device |
| DELETE | /devices/:id | Delete device |
Clients
| Method | Path | Description |
|---|---|---|
| GET | /clients | List clients (paginated, searchable) |
| GET | /clients/:id | Get client details with related data (repairs, orders, warranties) |
| POST | /clients | Create a new client |
| PATCH | /clients/:id | Update client |
| DELETE | /clients/:id | Delete client |
Orders
| Method | Path | Description |
|---|---|---|
| GET | /orders | List orders (paginated, searchable) |
| GET | /orders/:id | Get order details |
| POST | /orders | Create a new order |
| PATCH | /orders/:id | Update order |
| DELETE | /orders/:id | Delete order |
Repairs
| Method | Path | Description |
|---|---|---|
| GET | /repairs | List repairs (paginated, searchable) |
| GET | /repairs/:id | Get repair details |
| POST | /repairs | Create a new repair |
| PATCH | /repairs/:id | Update repair |
| DELETE | /repairs/:id | Delete repair |
Tickets (Support)
| Method | Path | Description |
|---|---|---|
| GET | /tickets | List support tickets (paginated, searchable) |
| GET | /tickets/:id | Get ticket with messages |
| POST | /tickets | Create a new ticket |
| PATCH | /tickets/:id | Update ticket OR add a message |
Add a message to a ticket: PATCH /api/mobile/tickets/:id with { "message": "...", "reopen": true }
Notifications
| Method | Path | Description |
|---|---|---|
| GET | /notifications | List notifications (?unreadOnly=true to filter) |
| PATCH | /notifications | Mark as read ({ "id": "..." } for one, empty body = all) |
Warranties
| Method | Path | Description |
|---|---|---|
| GET | /warranties | List warranties (paginated, searchable) |
| POST | /warranties | Create a warranty |
Trade-Ins
| Method | Path | Description |
|---|---|---|
| GET | /trade-ins | List user's trade-in submissions (paginated) |
| POST | /trade-ins | Submit a trade-in request |
Inventory
| Method | Path | Description |
|---|---|---|
| GET | /inventory | List inventory items (paginated, searchable) |
| POST | /inventory | Add an inventory item |
Billing
| Method | Path | Description |
|---|---|---|
| GET | /billing | Get wallet balance, plan info, and transaction history |
Pagination & Search
All list endpoints support these optional query parameters.
| Parameter | Default | Description |
|---|---|---|
page | 1 | Page number |
limit | 20 | Items per page (max 100) |
search | — | Search across relevant fields |
sortBy | createdAt | Field to sort by |
sortOrder | desc | asc or desc |
Paginated Response Format
{
"success": true,
"data": [
"..."
],
"pagination": {
"page": 1,
"limit": 20,
"total": 50,
"totalPages": 3
}
}Usage with API Client
// List with search and pagination
const result = await api.devices.list({
page: 1,
limit: 20,
search: 'Samsung',
sortBy: 'createdAt',
sortOrder: 'desc',
});
console.log(result.data); // Device[]
console.log(result.pagination); // { page, limit, total, totalPages }Error Handling
All errors follow a consistent format and can be caught using the built-in ApiError class.
{
"success": false,
"error": "Error message"
}Error Handling with the API Client
import { ApiError } from './api-client';
try {
const result = await api.devices.list();
} catch (error) {
if (error instanceof ApiError) {
console.error('Status:', error.status); // 400, 401, 404, 500
console.error('Message:', error.message);
console.error('Body:', error.body);
if (error.status === 401) {
// Token expired — redirect to login
await SecureStore.deleteItemAsync('authToken');
api.setToken(null);
navigation.navigate('Login');
}
}
}| Status | Meaning |
|---|---|
| 400 | Bad Request — Invalid input |
| 401 | Unauthorized — Missing or invalid token |
| 404 | Not Found — Resource does not exist |
| 500 | Internal Server Error |