> For the complete documentation index, see [llms.txt](https://autokin.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://autokin.gitbook.io/docs/features/autokin-generators.md).

# Autokin Generators

In some cases we want to include auto generated data as part of the API request, some of these are emails, ids, names, and maybe passwords. With Autokin Generators, this can be done as well with minimal syntax to understand.

### Generate Email Addresses <a href="#generate-email-addresses" id="generate-email-addresses"></a>

```
Scenario: Login to the system
    Given that a secure endpoint is up at {host}
    Given I set Content-Type header to application/json
    Given I set the JSON body to 
    """
    {
        "username": "{generate:email(gmail.com)}",
        "password": "p3dr0"
    }
    """
    When I POST /login
```

### Generate Passwords <a href="#generate-passwords" id="generate-passwords"></a>

```
Scenario: Login to the system
    Given that a secure endpoint is up at {host}
    Given I set Content-Type header to application/json
    Given I set the JSON body to 
    """
    {
        "username": "me@gmail.com",
        "password": "{generate:any(8,numbers,uppercase,lowercase)}"
    }
    """
    When I POST /login
```

This will generate password with length of 8 characters that can be either numbers, uppercase letters, or lowercase letters. If you want symbols just add it from the list.

### Generate Names <a href="#generate-names" id="generate-names"></a>

```
Scenario: Create Customer to the system
    Given that a secure endpoint is up at {host}
    Given I set Content-Type header to application/json
    Given I set the JSON body to 
    """
    {
        "username": "{generate:emails(gmail.com)}",
        "password": "{generate:any(8,numbers,uppercase,lowercase)}",
        "firstname": "{generate:firstname(male)}",
        "lastname": "{generate:lastname}"
    }
    """
    When I POST /create
```

#### &#x20;<a href="#generators-references" id="generators-references"></a>

#### Generators References <a href="#generators-references" id="generators-references"></a>

| GENERATOR                             | DESCRIPTION                                                                                                                                                                                                                                                                                                                                          |
| ------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `{generate:email(domain)}`            | Generate random emails, with specified domain name. If not supplied it will have autokinjs.com as email domain.                                                                                                                                                                                                                                      |
| `{generate:firstname()}`              | Generate firstname base on existing name list, it can be either male or female.                                                                                                                                                                                                                                                                      |
| `{generate:firstname(male)}`          | Generate male firstname.                                                                                                                                                                                                                                                                                                                             |
| `{generate:firstname(female)}`        | Generate female firstname.                                                                                                                                                                                                                                                                                                                           |
| `{generate:lastname}`                 | Generate lastname base on existing list.                                                                                                                                                                                                                                                                                                             |
| `{generate:words(language,suffix)}`   | <p>Generate random adjective words in English (<code>en</code>) or Chinese (<code>zh</code>)<br><br>For example: <code>{generate:words(en,hello)}</code></p>                                                                                                                                                                                         |
| `{generate:uuid}`                     | Generate UUID v4.                                                                                                                                                                                                                                                                                                                                    |
| `{generate:any(length, ...options )}` | <p>Generate random characters based on length and options.<br><br> Options can be <code>numbers</code>, <code>lowercase</code>, <code>uppercase</code>, or <code>symbols</code>.<br><br>To generate only symbols: <code>{generate:any(10,symbols)}</code>. If you want both numbers and symbols: <code>{generate:any(10,numbers,symbols)}</code></p> |
| `{generate:timestamp(offset)}`        | Generate timestamp value. To generate timestamp 5 minutes ago, pass a `-5` as an offset. Make it non negative value and it will generate that minutes ahead of the current time.                                                                                                                                                                     |
