# Generate a random slug

`GET https://app.clik.so/api/links/generate-slug`

> **In short:** Returns a random short code that is free on the domain right now. Use it when you want to show the code before you create the link.

## You need

* **API key permission:** `read`
* **Workspace role:** viewer or higher
* **Plan:** any plan, including Free

## Example

```bash
curl "https://app.clik.so/api/links/generate-slug?domain=clik.is" \
  -H "Authorization: Bearer $CLIKSO_API_KEY"
```

Response 200:

```json
{
  "status": 200,
  "success": true,
  "message": "Success",
  "data": {
    "slug": "aB3x9Kq"
  }
}
```

## Parameters

| Name     | In    | Type   | Required | Description                                                   |
| -------- | ----- | ------ | -------- | ------------------------------------------------------------- |
| `domain` | query | string | no       | The domain the code should be free on. Defaults to `clik.is`. |

## Common errors

| Status | Code           | When                                            |
| ------ | -------------- | ----------------------------------------------- |
| 401    | `UNAUTHORIZED` | The API key is missing, malformed or unknown.   |
| 429    | `RATE_LIMITED` | The key went over its per-minute request limit. |

## Good to know

* The code is 7 characters from letters and digits. If many collide, it can be 9 characters.
* It is not reserved. Create the link soon, and handle `409 CONFLICT` in case someone took it.
* You do not need this to create a link: leave out `short_code` and Clikso picks one for you.

---

Source: https://clik.so/docs/api/links/generate-slug
