# Contracts

## Contracts API

The Contracts API provides access to a list of contracts within a tenant. This API supports filtering, pagination, and sorting.

### API Endpoint

```http
GET /tenant/users/contracts
Host: api.audicient.com
Authorization: <API_KEY>:<API_SECRET>
```

### Query Parameters

| Parameter         | Type    | Description                                         | Default     |
| ----------------- | ------- | --------------------------------------------------- | ----------- |
| orderByDescending | boolean | Whether to sort results in descending order         | `true`      |
| orderByProperty   | string  | Field to sort by                                    | `createdAt` |
| pageSize          | number  | Number of results per page                          | `20`        |
| pageNumber        | number  | Page number for pagination                          | `1`         |
| fromDate          | string  | Filter contracts created from this date (optional)  | `null`      |
| toDate            | string  | Filter contracts created up to this date (optional) | `null`      |
| searchText        | string  | Search term for contract filtering (optional)       | `null`      |

### Authentication Requirements

All requests must include authentication credentials.

* **Authorization Header:** Pass the API key and secret as `<API_KEY>:<API_SECRET>`.

### Example Request

```http
GET /tenant/users/contracts?pageSize=10&pageNumber=1&orderByProperty=enterpriseName&orderByDescending=false
Host: api.audicient.com
Authorization: <API_KEY>:<API_SECRET>
```

### Example Response

```json
{
  "totalItemsCount": 2,
  "pageNumber": 1,
  "pageSize": 100,
  "items": [
    {
      "enterpriseId": 100001,
      "payeeId": 100001,
      "sharePercentage": 50,
      "enterpriseName": "Example Music Group",
      "subscriptionPlanId": 1,
      "type": "user",
      "permissionId": "abcd1234-5678-90ef-ghij-klmnopqrstuv",
      "ownerImageId": "1234abcd-5678-90ef-ghij-klmnopqrstuv",
      "ownerEmail": "owner@example.com",
      "ownerUserId": "abcd5678-90ef-ghij-klmnopqrstuv1234",
      "ownerFirstName": "John",
      "ownerLastName": "Doe",
      "createdAt": "2025-03-10T10:00:00.000Z"
    },
    {
      "enterpriseId": 100002,
      "payeeId": 100002,
      "sharePercentage": 70,
      "enterpriseName": "Global Sound Records",
      "subscriptionPlanId": 2,
      "type": "user",
      "permissionId": "xyz1234-5678-90ef-ghij-klmnopqrstuv",
      "ownerImageId": null,
      "ownerEmail": "user@globalsound.com",
      "ownerUserId": "xyz5678-90ef-ghij-klmnopqrstuv1234",
      "ownerFirstName": "Jane",
      "ownerLastName": "Smith",
      "createdAt": "2025-03-12T12:30:00.000Z"
    }
  ],
  "additionalCounters": null
}
```
