# C API: Award items

Items a game defines and unlocks for its signed-in players, who then wear them in their 360sona wardrobe: [custom items: award items](../../guides/custom-items.md#award-items-from-your-own-game).

## sona_award_def_defaults

```c
void sona_award_def_defaults(sona_award_def *d);
```

| Parameter | Type | Meaning | Default |
|---|---|---|---|
| `d` | `sona_award_def *` | The [`sona_award_def`](../fields.md#sona_award_def) to fill with the defaults | required |

**Returns** Nothing.

**Example**:

```c
sona_award_def x_award_def;
sona_award_def_defaults(&x_award_def);
sona_award_def_defaults(&x_award_def);
```

`size` set and everything else zero.

## sona_award_define

```c
sona_result sona_award_define(sona_ctx *ctx, const sona_award_def *d, uint32_t *ticket);
```

| Parameter | Type | Meaning | Default |
|---|---|---|---|
| `ctx` | `sona_ctx *` | The context | required |
| `d` | `const sona_award_def *` | The options, a [`sona_award_def`](../fields.md#sona_award_def) | required |
| `ticket` | `uint32_t *` | Receives a ticket for `sona_award_poll` | required |

**Returns** `SONA_OK`. **Errors** `SONA_E_ARGUMENT`, `SONA_E_LIMIT`, `SONA_E_MEMORY`, `SONA_E_IO`, `SONA_E_APP` ([what each means](../../troubleshooting.md#error-codes)).

Defines an award item for an app with the app's developer key (a tool's call, never a shipped game's). It goes to `config.check_host` through the ctx's HTTP layer and gives a ticket: `sona_award_poll` after `sona_update` says how it went.

## sona_award_unlock

```c
sona_result sona_award_unlock(sona_ctx *ctx, const char *player_token, const char *key, uint32_t *ticket);
```

| Parameter | Type | Meaning | Default |
|---|---|---|---|
| `ctx` | `sona_ctx *` | The context | required |
| `player_token` | `const char *` | The signed-in player's access token | required |
| `key` | `const char *` | The award's key | required |
| `ticket` | `uint32_t *` | Receives a ticket for `sona_award_poll` | required |

**Returns** `SONA_OK`. **Errors** `SONA_E_ARGUMENT`, `SONA_E_LIMIT`, `SONA_E_MEMORY`, `SONA_E_IO`, `SONA_E_APP` ([what each means](../../troubleshooting.md#error-codes)).

`player_token`: the signed-in player's access token (Sign in with 360sona).

## sona_award_poll

```c
sona_result sona_award_poll(sona_ctx *ctx, uint32_t ticket);
```

| Parameter | Type | Meaning | Default |
|---|---|---|---|
| `ctx` | `sona_ctx *` | The context | required |
| `ticket` | `uint32_t` | The ticket the request gave | - |

**Returns** `SONA_OK`, `SONA_PENDING` while it is still working. **Errors** `SONA_E_ARGUMENT`, `SONA_E_NOT_FOUND`, `SONA_E_LIMIT`, `SONA_E_IO`, `SONA_E_GATE`, `SONA_E_APP` ([what each means](../../troubleshooting.md#error-codes)).

**Example**:

```c
sona_result result = sona_award_poll(ctx, 0);
if (result != SONA_OK) printf("sona_award_poll: %s\n", sona_result_name(result));
```

`SONA_PENDING` while it runs, then its result once: `SONA_OK`, `SONA_E_NOT_FOUND` (no such award), `SONA_E_APP` (a wrong key or token, or no awards scope), `SONA_E_ARGUMENT` (refused; see `sona_last_error`), `SONA_E_LIMIT`, `SONA_E_GATE` or `SONA_E_IO`.
