> ## Documentation Index
> Fetch the complete documentation index at: https://apidocs.royalti.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Expense

> **Create Expense**

<Note>
  This endpoint requires authentication. Include your Bearer token in the Authorization header.
</Note>

## Description

**Create Expense**

**Description:**\
The `/expense/` endpoint allows creation of expense records with detailed information including type, amount, splits, and associated files.

**Method:**\
`POST`

**Request Payload:**

| Parameter       | Type   | Description                                       |
| --------------- | ------ | ------------------------------------------------- |
| title           | string | Title/description of the expense                  |
| type            | string | Type of expense (product, artist, asset, general) |
| transactionDate | string | Date of the expense transaction                   |
| currency        | string | Currency code (e.g., USD, EUR)                    |
| amount          | number | Expense amount in specified currency              |
| amountUSD       | number | Expense amount converted to USD                   |
| conversionRate  | number | Exchange rate used for conversion                 |
| id              | string | Associated entity ID (product, artist, or asset)  |
| memo            | string | Additional notes about the expense                |
| files           | object | Associated files/receipts                         |
| split           | array  | Expense split information among users             |

## Code Examples

<CodeGroup>
  ```javascript Node.js theme={null}
  const response = await fetch('https://api.royalti.io/expense/', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${token}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      "title": "sample-title",
      "type": "sample-type",
      "transactionDate": "2024-01-21",
      "currency": "sample-currency",
      "amount": 1,
      "amountUSD": 1,
      "conversionRate": 1,
      "id": "sample-id",
      "artist": "sample-artist",
      "product": "sample-product",
      "asset": "sample-asset",
      "memo": "sample-memo",
      "files": "sample-files",
      "split": [
        {
          "user": "sample-user",
          "share": 1
        }
      ]
    })
  });

  const data = await response.json();
  console.log(data);
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
    'https://api.royalti.io/expense/',
    headers={
      'Authorization': f'Bearer {token}'
    },
    json={"title":"sample-title","type":"sample-type","transactionDate":"2024-01-21","currency":"sample-currency","amount":1,"amountUSD":1,"conversionRate":1,"id":"sample-id","artist":"sample-artist","product":"sample-product","asset":"sample-asset","memo":"sample-memo","files":"sample-files","split":[{"user":"sample-user","share":1}]}
  )

  data = response.json()
  print(data)
  ```

  ```bash cURL theme={null}
  curl -X POST https://api.royalti.io/expense/ \
    -H "Authorization: Bearer YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{"title":"sample-title","type":"sample-type","transactionDate":"2024-01-21","currency":"sample-currency","amount":1,"amountUSD":1,"conversionRate":1,"id":"sample-id","artist":"sample-artist","product":"sample-product","asset":"sample-asset","memo":"sample-memo","files":"sample-files","split":[{"user":"sample-user","share":1}]}'

  ```
</CodeGroup>


## OpenAPI

````yaml post /expense/
openapi: 3.0.0
info:
  title: Royalti.io API
  description: "# Royalti API\r\n\r\nThis is the Royalti music royalty management platform API server.\r\n\r\n## Overview\r\n\r\nThe Royalti API provides comprehensive music royalty management services including:\r\n- Music publishing and writer management\r\n- Royalty processing and analytics\r\n- DDEX integration for music industry standards\r\n- File processing and pattern recognition\r\n- Payment processing and distribution\r\n\r\n## Authentication\r\n\r\nThe API uses JWT-based authentication with multiple protection levels:\r\n- Public endpoints for basic operations\r\n- Protected endpoints requiring valid JWT tokens\r\n- Admin endpoints for administrative functions\r\n\r\n## Features\r\n\r\n- Multi-dimensional royalty analytics\r\n- CWR (Collective Works Registration) support\r\n- DDEX integration for music metadata\r\n- Advanced file processing with pattern recognition\r\n- Real-time data processing with queue system"
  version: 2.6.0
  contact:
    name: Royalti.io Support
    email: support@royalti.io
    url: https://royalti.io
  license:
    name: Proprietary
    url: https://royalti.io/terms
servers:
  - url: https://api.royalti.io
    description: Production server
  - url: https://api-dev.royalti.io
    description: Development server
  - url: http://localhost:8084
    description: Local development
security:
  - bearerAuth: []
tags:
  - name: Accounting
    description: Accounting and financial transaction operations
  - name: DDEX
    description: DDEX operations (ERN/MEAD, messages, delivery, providers)
  - name: Label
    description: Label management operations
  - name: Internal Webhooks
    description: Internal system webhooks for royalty processing and downloads
  - name: Payment Webhooks
    description: Payment processor webhook endpoints
  - name: Billing Webhooks
    description: Stripe billing and subscription webhooks
  - name: Infrastructure Webhooks
    description: Cloudflare domain and SSL webhooks
  - name: Distribution Webhooks
    description: Digital distribution platform webhooks (FUGA)
paths:
  /expense/:
    post:
      tags:
        - Expense
      summary: Create Expense
      description: >-
        **Create Expense**


        **Description:**  

        The `/expense/` endpoint allows creation of expense records with
        detailed information including type, amount, splits, and associated
        files.


        **Method:**  

        `POST`


        **Request Payload:**


        | Parameter | Type | Description |

        | --- | --- | --- |

        | title | string | Title/description of the expense |

        | type | string | Type of expense (product, artist, asset, general) |

        | transactionDate | string | Date of the expense transaction |

        | currency | string | Currency code (e.g., USD, EUR) |

        | amount | number | Expense amount in specified currency |

        | amountUSD | number | Expense amount converted to USD |

        | conversionRate | number | Exchange rate used for conversion |

        | id | string | Associated entity ID (product, artist, or asset) |

        | memo | string | Additional notes about the expense |

        | files | object | Associated files/receipts |

        | split | array | Expense split information among users |
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                title:
                  type: string
                  description: Title/description of the expense
                type:
                  type: string
                  description: Type of expense
                  enum:
                    - product
                    - artist
                    - asset
                    - general
                    - marketing
                    - production
                    - legal
                    - administrative
                transactionDate:
                  type: string
                  format: date
                  description: Date of the expense transaction
                currency:
                  type: string
                  description: Currency code (e.g., USD, EUR)
                amount:
                  type: number
                  description: Expense amount in specified currency
                amountUSD:
                  type: number
                  description: Expense amount converted to USD
                conversionRate:
                  type: number
                  description: Exchange rate used for conversion
                  default: 1
                id:
                  type: string
                  description: Associated entity ID (product, artist, or asset)
                artist:
                  type: string
                  description: Associated artist ID (when type is artist)
                product:
                  type: string
                  description: Associated product ID (when type is product)
                asset:
                  type: string
                  description: Associated asset ID (when type is asset)
                memo:
                  type: string
                  description: Additional notes about the expense
                files:
                  type: string
                  format: binary
                  description: Associated files/receipts
                split:
                  type: array
                  items:
                    type: object
                    properties:
                      user:
                        type: string
                        description: User ID for the split
                      share:
                        type: number
                        description: Percentage share of the expense
                  description: Expense split information among users
              required:
                - title
                - type
                - transactionDate
                - currency
                - amount
                - amountUSD
              example:
                title: Mavins sabi girl
                type: product
                transactionDate: '2023-03-14'
                currency: USD
                amount: 100
                amountUSD: 100
                id: 77ec1367-be7e-4c3c-a57f-79f6b7349952
                conversionRate: 1
                memo: Some memo
                files:
                  file1: file1.pdf
                  file2: file2.pdf
                split:
                  - user: 91f1d1bd-ef25-4990-bd4f-aeee696c73a9
                    share: 30
                  - user: 9ea08acc-e135-4bd9-b159-48339ff65061
                    share: 50
                  - user: b369dabe-b4e0-4787-91a5-b561c98601e5
                    share: 20
      responses:
        '201':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  expense:
                    type: object
                    properties:
                      id:
                        type: string
                      title:
                        type: string
                      type:
                        type: string
                      amount:
                        type: number
                      amountUSD:
                        type: number
                      currency:
                        type: string
                      transactionDate:
                        type: string
                        format: date
                      createdAt:
                        type: string
                        format: date-time
                      updatedAt:
                        type: string
                        format: date-time
              example:
                message: Expense created successfully
                expense:
                  id: expense-uuid-123
                  title: Mavins sabi girl
                  type: product
                  amount: 100
                  amountUSD: 100
                  currency: USD
                  transactionDate: '2023-03-14'
                  createdAt: '2023-03-14T10:30:00.000Z'
                  updatedAt: '2023-03-14T10:30:00.000Z'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                msg: product does not exist.
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - bearerAuth: []
components:
  schemas:
    Error:
      type: object
      properties:
        success:
          type: boolean
          example: false
        error:
          type: object
          properties:
            code:
              type: string
            message:
              type: string
            details:
              type: array
              items:
                type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        JWT Authorization header using the Bearer scheme. Format: "Bearer
        {token}"

````