Skip to main content

🏦 Accounts API

The Accounts API allows you to manage financial accounts within Pika. This includes checking accounts, savings accounts, credit cards, investment accounts, and other financial instruments. Each account tracks its balance, transactions, and metadata.

📡 Base URL

All accounts endpoints are prefixed with:

/wp-json/pika/v1/accounts

🚀 Endpoints

Get All Accounts

Retrieve all accounts for the authenticated user.

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

Headers:

  • Cookie: Authentication cookie

Query Parameters:

Response:

[
{
"id": "1",
"name": "Federal",
"description": "Main Account",
"avatar": {
"id": "1",
"url": "http:\/\/localhost:8000\/wp-content\/uploads\/pika\/avatars\/account-6889ac3ac6f73-175385289.jpg",
"type": "image",
"name": "1000118509.jpg",
"size": "9444"
},
"lastTransactionAt": null,
"totalTransactions": 0,
"balance": "-50921.7500",
"icon": "wallet",
"bgColor": "#3B82F6",
"color": "#ffffff"
},
{
"id": "3",
"name": "Pluxee",
"description": "Meal Account",
"avatar": {
"id": "3",
"url": "http:\/\/localhost:8000\/wp-content\/uploads\/pika\/avatars\/account-6889acc50c37c-17538899.png",
"type": "image",
"name": "1000118516.png",
"size": "4331"
},
"lastTransactionAt": null,
"totalTransactions": 0,
"balance": "-3181.4600",
"icon": "wallet",
"bgColor": "#3B82F6",
"color": "#ffffff"
},
{
"id": "2",
"name": "Wallet",
"description": "",
"avatar": null,
"lastTransactionAt": null,
"totalTransactions": 0,
"balance": "400.0000",
"icon": "wallet",
"bgColor": "#3B82F6",
"color": "#ffffff"
}
],

Example Request:

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

Get Account by ID

Retrieve a specific account by its ID.

Endpoint: GET /wp-json/pika/v1/accounts/{id}

Headers:

  • Cookie: Authentication cookie

Response:

{
"id": "1",
"name": "Federal",
"description": "Main Account",
"avatar": {
"id": "1",
"url": "http:\/\/localhost:8000\/wp-content\/uploads\/pika\/avatars\/account-6889ac3ac6f73-1753852899.jpg",
"type": "image",
"name": "1000118509.jpg",
"size": "9444"
},
"lastTransactionAt": null,
"totalTransactions": 0,
"balance": "-50921.7500",
"icon": "wallet",
"bgColor": "#3B82F6",
"color": "#ffffff"
}

Example Request:

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

Create Account

Create a new account.

Endpoint: POST /wp-json/pika/v1/accounts

Headers:

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

Request Body:

{
"name": "SBI",
"description": "Secondary account",
"icon": "trending-up",
"color": "#8b5cf6",
"bgColor": "#faf5ff"
}

Required Fields:

  • name (string): Account name

Optional Fields:

  • description (string): Account description
  • icon (string): Icon identifier
  • color (string): Text color (hex format)
  • bgColor (string): Background color (hex format)
  • avatarId (integer): Avatar image ID

Response:

{
"id": "3",
"name": "SBI",
"description": "Secondary account",
"avatar": null,
"lastTransactionAt": null,
"totalTransactions": 0,
"balance": "0",
"icon": "trending-up",
"bgColor": "#8b5cf6",
"color": "#faf5ff"
}

Example Request:

curl -X POST http://localhost:8000/wp-json/pika/v1/accounts \
-H "Cookie: pika_token=token" \
-H "Content-Type: application/json" \
-d '{
**Request Body:**
{
"name": "SBI",
"description": "Secondary account",
"icon": "trending-up",
"color": "#8b5cf6",
"bgColor": "#faf5ff"
}'

Update Account

Update an existing account.

Endpoint: PUT /wp-json/pika/v1/accounts/{id}

Headers:

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

Request Body:

{
"name": "SBI - Updated",
"color": "#7c3aed"
}

Response:

{
"id": "3",
"name": "SBI - Updated",
"description": "Secondary account",
"avatar": null,
"lastTransactionAt": null,
"totalTransactions": 0,
"balance": "0",
"icon": "trending-up",
"bgColor": "#7c3aed",
"color": "#faf5ff"
}

Example Request:

curl -X PUT http://localhost:8000/wp-json/pika/v1/accounts/4 \
-H "Cookie: pika_token=token" \
-H "Content-Type: application/json" \
-d '{
"name": "SBI - Updated",
"color": "#7c3aed"
}'

Delete Account

Delete an account. Accounts with transactions cannot be deleted.

Endpoint: DELETE /wp-json/pika/v1/accounts/{id}

Headers:

  • Cookie: Authentication cookie

Response:

{
"success": true,
"message": "Account deleted successfully"
}

Example Request:

curl -X DELETE http://localhost:8000/wp-json/pika/v1/accounts/4 \
-H "Cookie: pika_token=token"

🎨 Account Properties

Icon Options

Available Icons:

  • All Lucide icon names

Color Format

  • Text Color: Hex color code (e.g., #4ecdc4)
  • Background Color: Hex color code (e.g., #f0fdfa)
  • Recommended: Use contrasting colors for readability

🚨 Error Responses

Account Not Found

{
"code":"account_not_found",
"message":"Account not found",
"data":{
"status":404
}
}

Cannot Delete Account with Transactions

{
"code":"account_has_transactions",
"message":"Account has transactions. Please delete the transactions first.",
"data":{
"status":400
}
}

💡 Best Practices

  1. Account Naming

    • Use clear, descriptive names (Used by AI model)
    • Be consistent with naming conventions
  2. Balance Management

    • Let the system handle balance calculations
    • Only manually adjust for reconciliation