# Sending and Managing a Gift

## Sending a Gift by Placing an Order

You may send gift(s) by submitting an `Order` request. A single `Order` request can contain multiple `gifts`, each assigned to a single recipient. Each recipient must have either an `employeeNumber` or an `email`. In case both are present, `email` will take precedence.

An `Order` request can include a mix of gifts, with some recipients identified by `employeeNumber` and others by `email`. Requesters may also specify an optional `X-Customer-Request-Id` for reference.

For details on required fields and request structure, refer to the [Orders API](/version/openapi/order-gift/sendorder). Upon successful submission, the API will return a `requestId`, which can be used to track the status of the order.

```shell curl
curl -i -X POST \
  https://api-demo.guusto.io/api/v1/orders \
  -H 'Authorization: Bearer <YOUR_ApiToken_HERE>' \
  -H 'Content-Type: application/json' \
  -H 'X-Customer-Request-Id: Gf3rf11-181e-443f9-aba5-aeasf32203e1' \
  -H 'X-Workspace-id: 444' \
  -d '{
    "orderItems": [
      {
        "message": "Awesome work! A little something from me",
        "amount": 10,
        "recipient": {
          "firstName": "John",
          "lastName": "Doe",
          "email": "johnDoe@guusto.com"
        }
      }
    ],
    "currency": "CAD",
    "language": "EN_CA"
  }'
```

```json 201 application/json
{
  "requestId": "c3c0029f-181e-41f9-aba5-ae99602203e1",
  "requestStatus": "ACCEPTED",
  "orderStep": "PENDING",
  "orderId": null,
  "customerRequestId": "Gf3rf11-181e-443f9-aba5-aeasf32203e1"
}
```

```json 400 application/json
{
  "status": 400,
  "message": "Validation failed for one or more fields",
  "type": "invalid_field"
}
```

```json 401 application/json
{
  "status": 401,
  "message": "You do not have the right authentication to access this resource.",
  "type": "security_error"
}
```

```json 403 application/json
{
  "status": 403,
  "message": "You do not have authorization to access this resource.",
  "type": "security_error"
}
```

```json 500 application/json
{
  "status": 500,
  "message": "Something happened on our side",
  "type": "server_error"
}
```

## Checking the Status of a Gift Order

To check the status of a gift order, use the [Order Status API](/version/openapi/order-gift/getorderstatus). The response provides details about the current state of your order, allowing you to track its progress.

```shell curl
curl -i -X GET \
  https://api-demo.guusto.io/api/v1/orders/status/c3c0029f-181e-41f9-aba5-ae99602203e1 \
  -H 'Authorization: Bearer <YOUR_ApiToken_HERE>' \
  -H 'X-Workspace-id: 444'
```

```json 200 application/json
{
  "requestId": "c3c0029f-181e-41f9-aba5-ae99602203e1",
  "requestStatus": "COMPLETED",
  "orderStep": "COMPLETED",
  "orderId": 444350,
  "customerRequestId": null
}
```

```json 400 application/json
{
  "status": 400,
  "message": "Bad Request - Input could be invalid",
  "type": "invalid_field"
}
```

```json 401 application/json
{
  "status": 401,
  "message": "You do not have the right authentication to access this resource.",
  "type": "security_error"
}
```

```json 403 application/json
{
  "status": 403,
  "message": "You do not have authorization to access this resource.",
  "type": "security_error"
}
```

```json 404 application/json
{
  "status": 404,
  "message": "Order request not found",
  "type": "invalid_field"
}
```

```json 500 application/json
{
  "status": 500,
  "message": "Something happened on our side",
  "type": "server_error"
}
```

## Find Order

Retrieve orders placed within a workspace using the [Find Order API](/version/openapi/order-gift/findorder). This is a **paginated resource**, please refer to the API documentation for pagination details and response structure.

```shell curl
curl -i -X GET \
  'https://api-demo.guusto.io/api/v1/orders/c3c0029f-181e-41f9-aba5-ae99602203e1?page=1&size=10' \
  -H 'Authorization: Bearer <YOUR_ApiToken_HERE>' \
  -H 'X-Workspace-id: 444'
```

```json 200 application/json
{
  "page": 1,
  "size": 1,
  "totalElements": 1,
  "totalPages": 1,
  "id": 444350,
  "requestId": "c3c0029f-181e-41f9-aba5-ae99602203e1",
  "state": "COMPLETED",
  "status": "COMPLETE",
  "certificates": [
    {
      "id": 123123,
      "currency": "CAD",
      "senderName": "John Doe",
      "recipientUser": 2323,
      "amount": 10,
      "message": "Thank you for your hard work!",
      "longToken": "KNEJ89JkAJ2KJL82kJnIJ2",
      "shortToken": "JKNW2"
    }
  ]
}
```

```json 400 application/json
{
  "status": 400,
  "message": "Bad Request - Input could be invalid",
  "type": "invalid_field"
}
```

```json 401 application/json
{
  "status": 401,
  "message": "You do not have the right authentication to access this resource.",
  "type": "security_error"
}
```

```json 403 application/json
{
  "status": 403,
  "message": "You do not have authorization to access this resource.",
  "type": "security_error"
}
```

```json 404 application/json
{
  "status": 404,
  "message": "Order request not found",
  "type": "invalid_field"
}
```

```json 500 application/json
{
  "status": 500,
  "message": "Something happened on our side",
  "type": "server_error"
}
```