This document describes the REST API endpoints available in the VetText API.
Register a new user with a phone number and public key.
Request:
{
"data": {
"phone_number": "1234567890",
"public_key": "base64-encoded-public-key",
"timestamp": "1615482367000"
},
"signature": "base64-encoded-signature"
}
Response:
{
"message": "Registration successful",
"user_id": "user-uuid"
}
Request a verification code to be sent to a phone number.
Request:
{
"data": {
"phone_number": "1234567890",
"timestamp": "1615482367000"
},
"signature": "base64-encoded-signature"
}
Response:
{
"message": "Verification code sent"
}
Login with a verification code.
Request:
{
"data": {
"verification_code": "123456",
"user_id": "user-uuid",
"timestamp": "1615482367000"
},
"signature": "base64-encoded-signature"
}
Response:
{
"access_token": "jwt-token",
"refresh_token": "refresh-token",
"user_id": "user-uuid"
}
Refresh an access token using a refresh token.
Request:
{
"data": {
"refresh_token": "refresh-token",
"user_id": "user-uuid",
"timestamp": "1615482367000"
},
"signature": "base64-encoded-signature"
}
Response:
{
"access_token": "new-jwt-token",
"refresh_token": "new-refresh-token"
}
Revoke a refresh token.
Request:
{
"data": {
"refresh_token": "refresh-token",
"user_id": "user-uuid",
"timestamp": "1615482367000"
},
"signature": "base64-encoded-signature"
}
Response:
{
"message": "Logged out successfully"
}
Get user profiles by IDs.
Headers:
Authorization: Bearer jwt-token
Response:
[
{
"id": "user-uuid",
"phone_number": "1234567890",
"public_key": "base64-encoded-public-key",
"scope": "client",
"first_name": "John",
"last_name": "Doe",
"email": "[email protected]",
"address": "123 Main St, Anytown, USA",
"profile_image_url": "https://example.com/profile.jpg",
"verified": true,
"created_at": 1615482367000,
"updated_at": 1615482367000
}
]
Update user profile information and manage pets.
Headers:
Authorization: Bearer jwt-token
Request:
{
"first_name": "John",
"last_name": "Doe",
"email": "[email protected]",
"address": "123 Main St, Anytown, USA",
"profile_image_url": "https://example.com/profile.jpg",
"pets": [
{
"id": "pet-uuid", // Include for existing pets
"name": "Buddy",
"breed": "Golden Retriever",
"sex": "M",
"birthday": 1546300800000,
"pet_image_url": "https://example.com/buddy.jpg",
"color": "Golden",
"species": "Dog",
"spayed_neutered": true,
"weight": 65
}
]
}
Response:
{
"message": "Profile updated successfully",
"user": {
"id": "user-uuid",
"phone_number": "1234567890",
"public_key": "base64-encoded-public-key",
"scope": "client",
"first_name": "John",
"last_name": "Doe",
"email": "[email protected]",
"address": "123 Main St, Anytown, USA",
"profile_image_url": "https://example.com/profile.jpg",
"verified": true,
"created_at": 1615482367000,
"updated_at": 1615482367000
},
"pets": [
{
"id": "pet-uuid",
"user_id": "user-uuid",
"name": "Buddy",
"breed": "Golden Retriever",
"sex": "M",
"birthday": 1546300800000,
"pet_image_url": "https://example.com/buddy.jpg",
"color": "Golden",
"species": "Dog",
"spayed_neutered": true,
"weight": 65
}
]
}
Delete a user account and all associated data.
Request:
{
"data": {
"user_id": "user-uuid",
"timestamp": "1615482367000"
},
"signature": "base64-encoded-signature"
}
Response:
{
"message": "Account deleted successfully"
}
Create a new pet or update an existing pet.
Headers:
Authorization: Bearer jwt-token
Create a new pet:
{
"name": "Max",
"breed": "Golden Retriever",
"sex": "M",
"birthday": "2020-01-15",
"pet_image_url": "https://example.com/pet_image.jpg"
}
Update an existing pet:
{
"id": "e1bf84be-0d14-42ec-8f1c-77918c3b9259",
"name": "Updated Pet Name",
"breed": "Updated Breed",
"sex": "M"
}
Response (Creating):
{
"message": "Pet created successfully",
"pet": {
"id": "e1bf84be-0d14-42ec-8f1c-77918c3b9259",
"user_id": "a1b2c3d4-e5f6-4a5b-8c9d-0e1f2a3b4c5d",
"name": "Max",
"breed": "Golden Retriever",
"sex": "M",
"birthday": 1579046400000,
"pet_image_url": "https://example.com/pet_image.jpg",
"color": null,
"species": null,
"spayed_neutered": null,
"weight": null
}
}
Response (Updating):
{
"message": "Pet updated successfully",
"pet": {
"id": "e1bf84be-0d14-42ec-8f1c-77918c3b9259",
"user_id": "a1b2c3d4-e5f6-4a5b-8c9d-0e1f2a3b4c5d",
"name": "Updated Pet Name",
"breed": "Updated Breed",
"sex": "M",
"birthday": 1579046400000,
"pet_image_url": "https://example.com/pet_image.jpg",
"color": "Brown",
"species": "Dog",
"spayed_neutered": true,
"weight": 25
}
}
Delete a pet from the user's account.
Headers:
Authorization: Bearer jwt-token
Request Body:
{
"id": "e1bf84be-0d14-42ec-8f1c-77918c3b9259"
}
Response:
{
"message": "Pet deleted successfully",
"pet_id": "e1bf84be-0d14-42ec-8f1c-77918c3b9259"
}
Upload an image file.
Headers:
Authorization: Bearer jwt-token
Query Parameters:
image_type
: Type of image (profile or pet)
Request: Multipart form data with a file field.
Response:
{
"message": "Image uploaded successfully",
"image": {
"id": "image-uuid",
"user_id": "user-uuid",
"filename": "image.jpg",
"content_type": "image/jpeg",
"image_type": "profile",
"image_url": "https://storage.googleapis.com/bucket/image.jpg",
"created_at": 1615482367000,
"updated_at": 1615482367000
}
}
Get images for the authenticated user.
Headers:
Authorization: Bearer jwt-token
Query Parameters:
image_type
(optional): Filter by image type (profile or pet)
Response:
[
{
"id": "image-uuid",
"user_id": "user-uuid",
"filename": "image.jpg",
"content_type": "image/jpeg",
"image_type": "profile",
"image_url": "https://storage.googleapis.com/bucket/image.jpg",
"created_at": 1615482367000,
"updated_at": 1615482367000
}
]
A full description of the WebSocket API can be found in websockets.md.
Establish a WebSocket connection for real-time messaging.
The WebSocket API supports the following event types:
conversations
: Get list of conversationsmessage
: Send a message to a conversationnew_conversation
: Create a new conversationconversation_history
: Get message history for a conversationuser_joined
: User joined a conversationuser_left
: User left a conversationunsubscribed
: Confirmation of unsubscribing from a conversationnew_message
: Notification of a new messageconversations_list
: Response with list of conversationsconversation_history_response
: Response with conversation historyerror
: Error message
- Always handle connection errors and implement reconnection logic.
- Subscribe to conversations as soon as the connection is established.
- Store conversation and message IDs locally to avoid duplicate messages.
- Use the
page
andlimit
parameters for pagination when fetching conversation history. - When uploading images, ensure they are in a supported format (jpg, jpeg, png, gif).
- Use the image URLs returned from the
/upload-image
endpoint to update profile or pet images.