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

# Accept Order

> Accept a new order and set preparation time

## Overview

Accepts an order that's in `RECEIVED` status and changes it to `CONFIRMED`. You must provide the estimated preparation time in minutes.

## Path Parameters

<ParamField path="order_id" type="string" required>
  Order's `payment_key` (UUID) from the `/get-current` response
</ParamField>

## Headers

<ParamField header="Access-Token" type="string" required>
  Your API access token
</ParamField>

<ParamField header="Content-Type" type="string" required>
  Must be `application/json`
</ParamField>

## Body Parameters

<ParamField body="preparing_time" type="integer" required>
  Estimated preparation time in minutes (e.g., 30)
</ParamField>

## Response

<ResponseField name="status" type="boolean">
  `true` if successful
</ResponseField>

<ResponseField name="data" type="string">
  `"OK"` on success
</ResponseField>

## Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl -X PUT https://www.xn--dkkango-n2a.com/api/integrations/orders/accept/3e9caf87-5cb7-4c4e-adcb-fc2ec54cf24e \
    -H 'Access-Token: your-access-token' \
    -H 'Content-Type: application/json' \
    -d '{"preparing_time": 30}'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'https://www.xn--dkkango-n2a.com/api/integrations/orders/accept/3e9caf87-5cb7-4c4e-adcb-fc2ec54cf24e',
    {
      method: 'PUT',
      headers: {
        'Access-Token': 'your-access-token',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        preparing_time: 30
      })
    }
  );

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

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

  response = requests.put(
      'https://www.xn--dkkango-n2a.com/api/integrations/orders/accept/3e9caf87-5cb7-4c4e-adcb-fc2ec54cf24e',
      headers={
          'Access-Token': 'your-access-token',
          'Content-Type': 'application/json'
      },
      json={'preparing_time': 30}
  )

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

## Success Response (200)

```json theme={null}
{
  "status": true,
  "data": "OK"
}
```

## Error Responses

<ResponseExample>
  ```json Missing Field (422) theme={null}
  {
    "status": false,
    "error": "eksik alan",
    "message": "preparing_time is required"
  }
  ```

  ```json Invalid UUID (403) theme={null}
  {
    "status": false,
    "error": "URL hatalı"
  }
  ```

  ```json Order Not Found (404) theme={null}
  {
    "status": false,
    "error": "sipariş bulunamadı"
  }
  ```

  ```json Authentication Error (401) theme={null}
  {
    "status": false,
    "error": "yetkisiz erişim"
  }
  ```
</ResponseExample>

## Status Transition

```
RECEIVED (status_id: 1)
    ↓
[/orders/accept called]
    ↓
CONFIRMED (status_id: 2)
```

<Note>
  After accepting, the order status history is automatically updated by the database trigger.
</Note>

## Integration Flow

<Steps>
  <Step title="Receive Order">
    Get order from `/orders/get-current` with `status_id: 1`
  </Step>

  <Step title="Acknowledge">
    Call `/orders/success/{payment_key}` to acknowledge receipt
  </Step>

  <Step title="Review">
    Staff reviews order details and decides to accept/reject
  </Step>

  <Step title="Accept">
    Call `/orders/accept/{payment_key}` with estimated prep time
  </Step>

  <Step title="Prepare">
    Kitchen prepares the order
  </Step>
</Steps>

## Preparation Time Guidelines

<AccordionGroup>
  <Accordion title="How to Calculate">
    Consider:

    * Current kitchen load
    * Order complexity (number of items, modifiers)
    * Time of day
    * Staff availability
  </Accordion>

  <Accordion title="Recommended Values">
    * Simple orders: 15-20 minutes
    * Medium orders: 25-35 minutes
    * Complex orders: 35-45 minutes
    * Peak hours: Add 10-15 minutes buffer
  </Accordion>

  <Accordion title="Impact on Customer">
    The preparation time is communicated to the customer and affects:

    * Estimated delivery time
    * Courier dispatch timing
    * Customer satisfaction
  </Accordion>
</AccordionGroup>

<Warning>
  Always use the `payment_key` (UUID) from the order object, not the `id` (integer).
</Warning>

## Related Endpoints

<CardGroup cols={2}>
  <Card title="Get Current Orders" icon="list" href="/api-reference/orders/get-current">
    Fetch orders to accept
  </Card>

  <Card title="Cancel Order" icon="xmark" href="/api-reference/orders/cancel">
    Reject/cancel order instead
  </Card>

  <Card title="Mark On The Way" icon="truck" href="/api-reference/orders/ontheway">
    Next step after preparation
  </Card>

  <Card title="Order Lifecycle" icon="route" href="/guides/order-lifecycle">
    Complete order flow
  </Card>
</CardGroup>
