Skip to main content

⚙️ Settings API

The Settings API allows you to manage user preferences, application configuration, and system settings. This includes currency settings, AI configuration, and other user-specific preferences.

📡 Base URL

All settings endpoints are prefixed with:

/wp-json/pika/v1/settings

🚀 Endpoints

Get Settings

Retrieve all current settings for the authenticated user.

Endpoint: GET /wp-json/pika/v1/settings

Headers:

  • Cookie: Authentication cookie

Response:

{
"currency": "INR",
"gemini_api_key": "gemini-key",
"timezone": "Asia\/Kolkata"
}

Example Request:

curl -X GET http://localhost:8000/wp-json/pika/v1/settings \
-H "Cookie: pika_token=token"

Update Settings

Update one or more settings for the authenticated user.

Endpoint: PUT /wp-json/pika/v1/settings

Headers:

  • Cookie: Authentication cookie
  • Content-Type: application/json

Request Body:

{
"timezone":"Africa/Abidjan"
}

Response:

{
"timezone":"Africa/Abidjan"
}

🔧 Configuration Options

Currency Settings

Supported Currencies:

  • USD - US Dollar
  • EUR - Euro
  • GBP - British Pound
  • INR - Indian Rupee
  • JPY - Japanese Yen
  • CAD - Canadian Dollar
  • AUD - Australian Dollar
  • And many more...

Example Request:

curl -X PUT http://localhost:8000/wp-json/pika/v1/settings \
-H "Cookie: pika_token=token" \
-H "Content-Type: application/json" \
-d '{
"currency": "INR"
}'

AI Configuration

Gemini API Key:

curl -X PUT http://localhost:8000/wp-json/pika/v1/settings \
-H "Cookie: pika_token=token" \
-H "Content-Type: application/json" \
-d '{
"gemini_api_key": "AIzaSyD-sample-api-key"
}'

🚨 Error Responses

Invalid Key

This is a generic error used when a key provided in a key-value pair is not recognized or does not conform to expected validation rules.

{
"code": "invalid_key",
"message": "Invalid key.",
"data": {
"status": 400
}
}

Invalid Data Type

This error is returned when the value for a field is of the wrong data type. For example, providing a string where an integer is expected. ↔️

{
"code": "invalid_type",
"message": "Invalid data type.",
"data": {
"status": 400
}
}

Invalid Value

This general-purpose error indicates that the value provided for a field, while of the correct data type, is not valid. This can be due to failing validation rules, such as being outside a permitted range or not being in a list of allowed options.

{
"code": "invalid_value",
"message": "Invalid value.",
"data": {
"status": 400
}
}