# create

Use`greymatter create` to **create a specific object** in the Grey Matter mesh. Objects can be `zones`, `proxies`, `domains`, `routes,` `shared_rules`, and `clusters`.

## Usage

`greymatter [GLOBAL OPTIONS] create [OPTIONS] <object type>`

### Sample Usage

#### Create from JSON File

Resources can be created directly from files on disk through shell redirects like shown below. Using the file `listener-catalog.json` with the following content:

```
{
    "zone_key": "zone-default-zone",
    "name": "catalog",
    "ip": "0.0.0.0",
    "port": 8080,
    "protocol": "http_auto",
    "domain_keys": ["domain-*"],
    "tracing_config": null,
    "checksum": "5e3f86011c958c05fbb51a51f9363bd014bef5aa4505728daf4dd35db440ff01"
}
```

`greymatter create domain` will create the domain object from the given spec.

```
$ ./greymatter create domain < listener-catalog.json
[info] 2019/07/10 03:43:46 Preferring --api.key for authentication
{
  "domain_key": "domain-catalog",
  "zone_key": "zone-default-zone",
  "name": "catalog",
  "port": 8080,
  "redirects": null,
  "gzip_enabled": false,
  "cors_config": null,
  "aliases": null,
  "force_https": false,
  "checksum": "82581e0c56c2ad385e84234fe118ccf8cf8deb1852a5aa318eab887e9a2717d2"
}
```

#### Interactive Editor

By setting the `EDITOR` environment variable, the `greymatter` tool will open the editor of choice and let the user create the object directly.

```bash
EDITOR=vim greymatter create domain
```

After editing the JSON directly in vim, the returned object will look something like the below (depending on the user input).

```bash
[info] 2019/07/10 03:38:43 Preferring --api.key for authentication
{
  "domain_key": "domain-localhost",
  "zone_key": "zone-default",
  "name": "localhost",
  "port": 443,
  "redirects": null,
  "gzip_enabled": false,
  "cors_config": null,
  "aliases": null,
  "force_https": false,
  "checksum": "a35ccf0634599ac83b0b9cb61b07297e925f28bbc669a9a63cb65b9c6a6ea309"
}
```

#### Help

To list available commands run with the global help flag, `greymatter create --help`:

```
$ greymatter create --help
NAME
    create - create an object within the Grey Matter API

USAGE
    greymatter [GLOBAL OPTIONS] create [OPTIONS] <object type>

VERSION
    v1.2.1

DESCRIPTION
    object type is one of: zone, proxy, listener, domain, route, shared_rules, cluster

    Editor Selection

    When changes need to be made an initial version of the object can be presented in an
    editor. The command used to launch the editor is taken from the EDITOR environment
    variable and must block execution until the changes are saved and the editor is
    closed. The current editor command is 'vim'.

    Example EDITOR values:

        vim

        emacs

        atom -w

    Using STDIN

    For scripting purposes it may be useful to use STDIN to provide the created object
    instead of using an interactive editor. If so, simply make the new version available
    on STDIN through standard use of pipes.

    Example: cat "new_cluster.json" | greymatter create cluster

GLOBAL OPTIONS
    --api.header=header
            Specifies a custom header to send with every API request. Headers are given as
            name:value pairs. Leading and trailing whitespace will be stripped from the
            name and value. For multiple headers, this flag may be repeated or multiple
            headers can be delimited with commas.

    --api.host=host:port
            (default: localhost:80)
            The address (host:port) for API requests. If no port is given, it defaults to
            port 443 if --api.ssl is true and port 80 otherwise.

    --api.insecure
            (default: false)
            If true, don't validate server cert when using SSL for API requests

    --api.key=string
            (default: "none")
            [SENSITIVE] The auth key for API requests

    --api.prefix=value
            The url prefix for API requests. Forms the path part of <host>:<port><path>

    --api.ssl
            (default: true)
            If true, use SSL for API requests

    --api.sslCert=value
            Specifies the SSL cert to use for every API request.

    --api.sslKey=value
            Specifies the SSL key to use for every API request.

    --console.level=level
            (default: "info")
            (valid values: "debug", "info", "error", or "none")
            Selects the log level for console logs messages.

    --format=string
            (default: "json")
            The I/O format (json or yaml)

    --help  (default: false)
            Show a list of commands or help for one command

    --version
            (default: false)
            Print the version and exit

    Global options can also be configured via upper-case, underscore-delimited environment
    variables prefixed with "GREYMATTER_". For example, "--some-flag" becomes
    "GREYMATTER_SOME_FLAG". Command-line flags take precedence over environment variables.

OPTIONS
    --help  (default: false)
            Show a list of commands or help for one command

    --version
            (default: false)
            Print the version and exit

    Options can also be configured via upper-case, underscore-delimited environment
    variables prefixed with "GREYMATTER_CREATE_". For example, "--some-flag" becomes
    "GREYMATTER_CREATE_SOME_FLAG". Command-line flags take precedence over environment
    variables.
```

## Questions?

{% hint style="success" %}
**Need help with the CLI?**

Create an account at [Grey Matter Support](https://support.greymatter.io/support/home) to reach our team.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://greymatter.gitbook.io/grey-matter-documentation/usage/fabric/cli/create.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
