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

# Purchase Order Details API

> Retrieve full details of a purchase order including vendor, line items, matched invoices, and GRNs

## Authentication

All requests require an API key in the request headers.

**Headers:**

```
Authorization: Api-Key YOUR_API_KEY
```

## Request

### Path Parameters

| Parameter | Type   | Required | Description                                                                                    |
| --------- | ------ | -------- | ---------------------------------------------------------------------------------------------- |
| `poId`    | string | Yes      | The unique slug identifier of the purchase order (returned from the PO creation or search API) |

## Code Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET https://api.pazy.io/v1.0/procurement/purchase-order/po_slug_identifier \
    -H "Authorization: Api-Key YOUR_API_KEY"
  ```

  ```javascript JavaScript (Fetch API) theme={null}
  const response = await fetch('https://api.pazy.io/v1.0/procurement/purchase-order/po_slug_identifier', {
    method: 'GET',
    headers: {
      'Authorization': 'Api-Key YOUR_API_KEY'
    }
  });

  const result = await response.json();
  ```

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

  url = "https://api.pazy.io/v1.0/procurement/purchase-order/po_slug_identifier"
  headers = {
      "Authorization": "Api-Key YOUR_API_KEY"
  }

  response = requests.get(url, headers=headers)
  result = response.json()
  ```
</CodeGroup>

## Success Response

**HTTP Status:** `200 OK`

**Response Fields:**

| Field                                  | Type    | Description                                                                                                  |
| -------------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------ |
| `ok`                                   | boolean | Indicates whether the request was successful                                                                 |
| `data`                                 | object  | Contains the purchase order details                                                                          |
| `data.poId`                            | string  | Unique slug identifier for the purchase order                                                                |
| `data.poNumber`                        | string  | Purchase order number assigned to the document                                                               |
| `data.state`                           | string  | Current state of the PO. Possible values: `DRAFTED`, `PENDING`, `APPROVED`, `DECLINED`, `CLOSED`, `ARCHIVED` |
| `data.poType`                          | string  | Purchase order type. Possible values: `GOODS`, `SERVICES`                                                    |
| `data.matchingType`                    | string  | Matching type. Possible values: `TWO_WAY`, `THREE_WAY`                                                       |
| `data.currency`                        | string  | ISO 4217 currency code (e.g., `INR`)                                                                         |
| `data.amount`                          | number  | Total purchase order amount                                                                                  |
| `data.description`                     | string  | Short description for the purchase order                                                                     |
| `data.poDate`                          | string  | Purchase order date (ISO 8601 format, YYYY-MM-DD)                                                            |
| `data.deliveryDate`                    | string  | Requested delivery date (ISO 8601 format, YYYY-MM-DD)                                                        |
| `data.termsAndConditions`              | string  | Terms and conditions for the purchase order                                                                  |
| `data.additionalNotes`                 | string  | Additional notes for delivery or special requirements                                                        |
| `data.paymentTerms`                    | string  | Agreed payment terms                                                                                         |
| `data.vendor`                          | object  | Linked vendor information (`null` if no vendor linked)                                                       |
| `data.vendor.displayName`              | string  | Vendor display name                                                                                          |
| `data.vendor.legalName`                | string  | Vendor legal name                                                                                            |
| `data.lineItems`                       | array   | List of line items on the purchase order                                                                     |
| `data.lineItems[].identifier`          | string  | SKU or identifier for the line item                                                                          |
| `data.lineItems[].quantity`            | number  | Quantity requested                                                                                           |
| `data.lineItems[].rate`                | number  | Unit rate                                                                                                    |
| `data.lineItems[].amount`              | number  | Total amount for this line item (quantity × rate)                                                            |
| `data.matchedInvoices`                 | array   | List of invoices matched against this purchase order                                                         |
| `data.matchedInvoices[].invoiceId`     | string  | Unique identifier of the matched invoice                                                                     |
| `data.matchedInvoices[].invoiceNumber` | string  | Invoice number                                                                                               |
| `data.matchedInvoices[].state`         | string  | Current state of the invoice                                                                                 |
| `data.matchedInvoices[].amount`        | number  | Invoice amount                                                                                               |
| `data.matchedInvoices[].currency`      | string  | Invoice currency                                                                                             |
| `data.matchedInvoices[].invoiceDate`   | string  | Invoice date (ISO 8601 format)                                                                               |
| `data.matchedGrns`                     | array   | List of Goods Receipt Notes matched against this purchase order                                              |
| `data.matchedGrns[].grnId`             | string  | Unique identifier of the matched GRN                                                                         |
| `data.matchedGrns[].grnNumber`         | string  | GRN number                                                                                                   |
| `data.matchedGrns[].state`             | string  | Current state of the GRN                                                                                     |
| `data.matchedGrns[].amount`            | number  | GRN total amount                                                                                             |
| `data.matchedGrns[].totalQuantity`     | number  | Total quantity received in the GRN                                                                           |
| `data.matchedGrns[].createdAt`         | string  | Date the GRN was created (ISO 8601 format)                                                                   |

### PO State Values

| Value      | Description                            |
| ---------- | -------------------------------------- |
| `DRAFTED`  | PO is in draft state and can be edited |
| `PENDING`  | PO is pending approval                 |
| `APPROVED` | PO has been approved                   |
| `DECLINED` | PO was declined and can be edited      |
| `CLOSED`   | PO has been closed                     |
| `ARCHIVED` | PO has been archived                   |

### Response Example

```json theme={null}
{
  "ok": true,
  "data": {
    "poId": "po_slug_identifier",
    "poNumber": "PO-2024-001",
    "state": "APPROVED",
    "poType": "GOODS",
    "matchingType": "THREE_WAY",
    "currency": "INR",
    "amount": 12500.00,
    "description": "Office supplies purchase order",
    "poDate": "2024-01-15",
    "deliveryDate": "2024-02-15",
    "termsAndConditions": "All goods must be delivered in original packaging",
    "additionalNotes": "Please deliver during business hours",
    "paymentTerms": "Net 30 days",
    "vendor": {
      "displayName": "ABC Suppliers",
      "legalName": "ABC Suppliers Private Limited"
    },
    "lineItems": [
      {
        "identifier": "SKU-001",
        "quantity": 100,
        "rate": 50.00,
        "amount": 5000.00
      },
      {
        "identifier": "SKU-002",
        "quantity": 50,
        "rate": 75.00,
        "amount": 3750.00
      }
    ],
    "matchedInvoices": [
      {
        "invoiceId": "invoice_identifier",
        "invoiceNumber": "INV-2024-001",
        "state": "APPROVED",
        "amount": 12500.00,
        "currency": "INR",
        "invoiceDate": "2024-01-20"
      }
    ],
    "matchedGrns": [
      {
        "grnId": "grn_identifier",
        "grnNumber": "GRN-2024-001",
        "state": "APPROVED",
        "amount": 12500.00,
        "totalQuantity": 150,
        "createdAt": "2024-01-22T10:30:00Z"
      }
    ]
  }
}
```

## Error Responses

### Purchase Order Not Found

**HTTP Status:** `404 Not Found`

```json theme={null}
{
  "ok": false,
  "error": {
    "code": "PURCHASE_ORDER_NOT_FOUND",
    "message": "Purchase order not found"
  }
}
```

### Authentication Errors

**HTTP Status:** `401 Unauthorized`

```json theme={null}
{
  "ok": false,
  "error": {
    "code": "MISSING_CREDENTIALS",
    "message": "Missing Credentials"
  }
}
```

```json theme={null}
{
  "ok": false,
  "error": {
    "code": "INVALID_API_KEY",
    "message": "Invalid API Key"
  }
}
```

### Permission Errors

**HTTP Status:** `403 Forbidden`

```json theme={null}
{
  "ok": false,
  "error": {
    "code": "INSUFFICIENT_PERMISSIONS",
    "message": "Permission check failed - PERMISSION_CHECK_FAILED"
  }
}
```

### Internal Error

**HTTP Status:** `500 Internal Server Error`

```json theme={null}
{
  "ok": false,
  "error": {
    "code": "INTERNAL_ERROR",
    "message": "Internal error"
  }
}
```

## Best Practices

* Use the `poId` returned from the [Purchase Order Creation API](/apis/po-creation) to retrieve details
* The `matchedInvoices` array is populated when invoices are linked to the PO (TWO\_WAY or THREE\_WAY matching)
* The `matchedGrns` array is populated only for THREE\_WAY matching POs
* Check `state` to understand where the PO is in the approval workflow before taking further actions
