> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/No-Country-simulation/S02-26-Equipo-33-Web-App/llms.txt
> Use this file to discover all available pages before exploring further.

# Vet Records

> Manage veterinary records for horse listings

## Get Vet Records

<api>GET /api/horses/:id/vet-records</api>

Get all validated veterinary records for a horse listing.

### Authentication

Not required - Public endpoint

### Path Parameters

<ParamField path="id" type="string" required>
  Horse unique identifier
</ParamField>

### Response

<ResponseField name="success" type="boolean">
  Indicates if the request was successful
</ResponseField>

<ResponseField name="data" type="array">
  Array of validated vet records, sorted by review date (newest first)

  <ResponseField name="_id" type="string">
    Vet record unique identifier
  </ResponseField>

  <ResponseField name="horse_id" type="string">
    Horse ID
  </ResponseField>

  <ResponseField name="vet_id" type="string">
    Veterinarian user ID (if applicable)
  </ResponseField>

  <ResponseField name="review_date" type="string">
    Date of veterinary review
  </ResponseField>

  <ResponseField name="health_status" type="string">
    Overall health status description
  </ResponseField>

  <ResponseField name="certificates" type="array">
    Array of certificate documents

    <ResponseField name="_id" type="string">
      Certificate ID
    </ResponseField>

    <ResponseField name="url" type="string">
      Certificate document URL
    </ResponseField>

    <ResponseField name="title" type="string">
      Certificate title
    </ResponseField>

    <ResponseField name="uploaded_at" type="string">
      Upload timestamp
    </ResponseField>
  </ResponseField>

  <ResponseField name="vaccines" type="array">
    Array of vaccine records

    <ResponseField name="name" type="string">
      Vaccine name
    </ResponseField>

    <ResponseField name="applied_at" type="string">
      Date vaccine was applied
    </ResponseField>

    <ResponseField name="next_due_at" type="string">
      Next vaccine due date
    </ResponseField>

    <ResponseField name="batch_number" type="string">
      Vaccine batch number
    </ResponseField>
  </ResponseField>

  <ResponseField name="validation_status" type="string">
    Status: validated (only validated records returned)
  </ResponseField>

  <ResponseField name="validated_by" type="string">
    User ID of validator
  </ResponseField>

  <ResponseField name="validated_at" type="string">
    Validation timestamp
  </ResponseField>

  <ResponseField name="notes" type="string">
    Additional notes
  </ResponseField>

  <ResponseField name="created_at" type="string">
    Creation timestamp
  </ResponseField>

  <ResponseField name="updated_at" type="string">
    Last update timestamp
  </ResponseField>
</ResponseField>

### Example

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET "https://api.horsetrust.com/api/horses/507f1f77bcf86cd799439011/vet-records"
  ```

  ```javascript JavaScript theme={null}
  const horseId = '507f1f77bcf86cd799439011';
  const response = await fetch(`https://api.horsetrust.com/api/horses/${horseId}/vet-records`);
  const data = await response.json();
  console.log(data);
  ```

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

  horse_id = '507f1f77bcf86cd799439011'
  response = requests.get(
      f'https://api.horsetrust.com/api/horses/{horse_id}/vet-records'
  )
  data = response.json()
  print(data)
  ```
</CodeGroup>

<ResponseExample>
  ```json Response theme={null}
  {
    "success": true,
    "data": [
      {
        "_id": "65f1a2b3c4d5e6f7g8h9i0j1",
        "horse_id": "507f1f77bcf86cd799439011",
        "vet_id": "507f191e810c19729de860eb",
        "review_date": "2026-02-20T00:00:00Z",
        "health_status": "Excellent condition",
        "certificates": [
          {
            "_id": "65f1a2b3c4d5e6f7g8h9i0j2",
            "url": "https://cdn.horsetrust.com/certs/health_cert.pdf",
            "title": "Health Certificate",
            "uploaded_at": "2026-02-20T10:00:00Z"
          }
        ],
        "vaccines": [
          {
            "name": "Influenza",
            "applied_at": "2026-01-15T00:00:00Z",
            "next_due_at": "2026-07-15T00:00:00Z",
            "batch_number": "FLU2026-A123"
          },
          {
            "name": "Tetanus",
            "applied_at": "2026-01-15T00:00:00Z",
            "next_due_at": "2027-01-15T00:00:00Z",
            "batch_number": "TET2026-B456"
          }
        ],
        "validation_status": "validated",
        "validated_by": "507f191e810c19729de860ec",
        "validated_at": "2026-02-21T14:30:00Z",
        "notes": "Annual check-up completed. Horse in excellent health.",
        "created_at": "2026-02-20T10:00:00Z",
        "updated_at": "2026-02-21T14:30:00Z"
      }
    ]
  }
  ```
</ResponseExample>

***

## Add Vet Record

<api>POST /api/horses/:id/vet-record</api>

Add a new veterinary record to a horse listing (owner only).

### Authentication

Required - JWT Bearer token with `seller` or `admin` role

```bash theme={null}
Authorization: Bearer YOUR_JWT_TOKEN
```

### Authorization

Only the horse owner can add vet records to their listing.

### Path Parameters

<ParamField path="id" type="string" required>
  Horse unique identifier
</ParamField>

### Request Body

<ParamField body="review_date" type="string" required>
  Date of veterinary review (ISO 8601 format)
</ParamField>

<ParamField body="health_status" type="string" required>
  Overall health status description
</ParamField>

<ParamField body="certificates" type="array">
  Array of certificate documents

  <ParamField body="url" type="string" required>
    Certificate document URL
  </ParamField>

  <ParamField body="title" type="string">
    Certificate title/description
  </ParamField>
</ParamField>

<ParamField body="vaccines" type="array">
  Array of vaccine records

  <ParamField body="name" type="string" required>
    Vaccine name
  </ParamField>

  <ParamField body="applied_at" type="string" required>
    Date vaccine was applied (ISO 8601)
  </ParamField>

  <ParamField body="next_due_at" type="string">
    Next vaccine due date (ISO 8601)
  </ParamField>

  <ParamField body="batch_number" type="string">
    Vaccine batch number
  </ParamField>
</ParamField>

<ParamField body="vet_id" type="string">
  Veterinarian user ID (if applicable)
</ParamField>

<ParamField body="notes" type="string">
  Additional notes about the health review
</ParamField>

### Response

<ResponseField name="success" type="boolean">
  Indicates if the request was successful
</ResponseField>

<ResponseField name="data" type="object">
  Created vet record

  <ResponseField name="_id" type="string">
    Vet record unique identifier
  </ResponseField>

  <ResponseField name="horse_id" type="string">
    Horse ID
  </ResponseField>

  <ResponseField name="review_date" type="string">
    Review date
  </ResponseField>

  <ResponseField name="health_status" type="string">
    Health status
  </ResponseField>

  <ResponseField name="certificates" type="array">
    Certificates with generated IDs and timestamps
  </ResponseField>

  <ResponseField name="vaccines" type="array">
    Vaccine records
  </ResponseField>

  <ResponseField name="validation_status" type="string">
    Status: pending (awaits validation)
  </ResponseField>

  <ResponseField name="notes" type="string">
    Additional notes
  </ResponseField>

  <ResponseField name="created_at" type="string">
    Creation timestamp
  </ResponseField>

  <ResponseField name="updated_at" type="string">
    Last update timestamp
  </ResponseField>
</ResponseField>

### Notes

* New vet records are created with `validation_status: "pending"`
* Records must be validated by an admin before appearing in public listings
* Only the horse owner can add vet records
* `horse_id` is automatically set from the URL parameter

### Example

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://api.horsetrust.com/api/horses/507f1f77bcf86cd799439011/vet-record" \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer YOUR_JWT_TOKEN" \
    -d '{
      "review_date": "2026-03-01T00:00:00Z",
      "health_status": "Excellent condition, ready for competition",
      "certificates": [
        {
          "url": "https://cdn.horsetrust.com/certs/health_2026.pdf",
          "title": "Annual Health Certificate 2026"
        }
      ],
      "vaccines": [
        {
          "name": "Influenza",
          "applied_at": "2026-02-15T00:00:00Z",
          "next_due_at": "2026-08-15T00:00:00Z",
          "batch_number": "FLU2026-C789"
        },
        {
          "name": "Rabies",
          "applied_at": "2026-02-15T00:00:00Z",
          "next_due_at": "2027-02-15T00:00:00Z",
          "batch_number": "RAB2026-D012"
        }
      ],
      "notes": "Annual check-up. All vital signs normal. No issues detected."
    }'
  ```

  ```javascript JavaScript theme={null}
  const horseId = '507f1f77bcf86cd799439011';
  const response = await fetch(`https://api.horsetrust.com/api/horses/${horseId}/vet-record`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': 'Bearer YOUR_JWT_TOKEN'
    },
    body: JSON.stringify({
      review_date: '2026-03-01T00:00:00Z',
      health_status: 'Excellent condition, ready for competition',
      certificates: [
        {
          url: 'https://cdn.horsetrust.com/certs/health_2026.pdf',
          title: 'Annual Health Certificate 2026'
        }
      ],
      vaccines: [
        {
          name: 'Influenza',
          applied_at: '2026-02-15T00:00:00Z',
          next_due_at: '2026-08-15T00:00:00Z',
          batch_number: 'FLU2026-C789'
        },
        {
          name: 'Rabies',
          applied_at: '2026-02-15T00:00:00Z',
          next_due_at: '2027-02-15T00:00:00Z',
          batch_number: 'RAB2026-D012'
        }
      ],
      notes: 'Annual check-up. All vital signs normal. No issues detected.'
    })
  });

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

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

  horse_id = '507f1f77bcf86cd799439011'
  response = requests.post(
      f'https://api.horsetrust.com/api/horses/{horse_id}/vet-record',
      headers={
          'Content-Type': 'application/json',
          'Authorization': 'Bearer YOUR_JWT_TOKEN'
      },
      json={
          'review_date': '2026-03-01T00:00:00Z',
          'health_status': 'Excellent condition, ready for competition',
          'certificates': [
              {
                  'url': 'https://cdn.horsetrust.com/certs/health_2026.pdf',
                  'title': 'Annual Health Certificate 2026'
              }
          ],
          'vaccines': [
              {
                  'name': 'Influenza',
                  'applied_at': '2026-02-15T00:00:00Z',
                  'next_due_at': '2026-08-15T00:00:00Z',
                  'batch_number': 'FLU2026-C789'
              },
              {
                  'name': 'Rabies',
                  'applied_at': '2026-02-15T00:00:00Z',
                  'next_due_at': '2027-02-15T00:00:00Z',
                  'batch_number': 'RAB2026-D012'
              }
          ],
          'notes': 'Annual check-up. All vital signs normal. No issues detected.'
      }
  )

  data = response.json()
  print(data)
  ```
</CodeGroup>

<ResponseExample>
  ```json Response theme={null}
  {
    "success": true,
    "data": {
      "_id": "65f1a2b3c4d5e6f7g8h9i0j6",
      "horse_id": "507f1f77bcf86cd799439011",
      "review_date": "2026-03-01T00:00:00Z",
      "health_status": "Excellent condition, ready for competition",
      "certificates": [
        {
          "_id": "65f1a2b3c4d5e6f7g8h9i0j7",
          "url": "https://cdn.horsetrust.com/certs/health_2026.pdf",
          "title": "Annual Health Certificate 2026",
          "uploaded_at": "2026-03-05T16:00:00Z"
        }
      ],
      "vaccines": [
        {
          "name": "Influenza",
          "applied_at": "2026-02-15T00:00:00Z",
          "next_due_at": "2026-08-15T00:00:00Z",
          "batch_number": "FLU2026-C789"
        },
        {
          "name": "Rabies",
          "applied_at": "2026-02-15T00:00:00Z",
          "next_due_at": "2027-02-15T00:00:00Z",
          "batch_number": "RAB2026-D012"
        }
      ],
      "validation_status": "pending",
      "notes": "Annual check-up. All vital signs normal. No issues detected.",
      "created_at": "2026-03-05T16:00:00Z",
      "updated_at": "2026-03-05T16:00:00Z"
    }
  }
  ```
</ResponseExample>

### Error Responses

#### 401 - Unauthorized

```json theme={null}
{
  "success": false,
  "message": "Authentication required"
}
```

#### 403 - Forbidden

```json theme={null}
{
  "success": false,
  "message": "Seller role required"
}
```

#### 404 - Horse Not Found or Unauthorized

```json theme={null}
{
  "success": false,
  "message": "Horse not found or unauthorized"
}
```

#### 500 - Server Error

```json theme={null}
{
  "success": false,
  "message": "Server error"
}
```
