create-key

Create a key to access a child database.

Syntax

fauna create-key DBNAME [ROLE] [OPTIONS]

Description

The create-key command creates a key that allows access to the DBNAME child database.

When you create the key, you can optionally associate a role to the key:

  • admin (default)

  • server

  • server-readonly

  • User-defined role name.

If command line options are omitted, the default options from the configuration file are used.

You can’t use this command to create a key in a parent or peer database. To access a database outside of the current database, log into the Fauna Dashboard.

Arguments

Argument Description

DBNAME

Name of the database to create a key for.

ROLE

(Optional) Key role. One of:

  • admin (default)

  • server

  • server-readonly

  • User-defined role name

Options

Option Description

--domain=<domain>

(Optional) Fauna server domain, which is the Fauna hostname.
Default = db.fauna.com

--endpoint=<name>

(Optional) Endpoint name to use for the command.

--port=<number>

(Optional) Connection port.
Default = 8443

--scheme=<scheme>

(Optional) Connection scheme. Must be one of:
       https (default)
       http

--secret=<secret>

(Optional) Secret to use to connect to a database.

--timeout=<integer>

(Optional) connection timeout, in milliseconds. When the interval elapses, fauna-shell times out and displays an error.
Default = 0, wait indefinitely until a response is received.

--version

(Optional) Fauna Query Language version
       v10 = (default) FQL v10
       v4 = FQL v4

Example

This example uses a database called my-test-db.

fauna list-databases
listing databases
my-test-db

Now, run fauna create-key to create a key for my-test-db. Because a role is not provided, the key role defaults to admin.

fauna create-key my-test-db
creating key for database 'my-test-db' with role 'admin'

  created key for database 'my-test-db' with role 'admin'.
  secret: fnAFMpLEJWAAQasGbXhkW5wyvhpOIIkj-j1cmKng

  To access 'my-test-db' with this key, create a client using
  the driver library for your language of choice using
  the above secret.

Verify the key is created:

fauna list-keys
Key ID               Database             Role
373686120364376132   [current]            admin
373711801788923969   [current]            server
373714670256652356   internal             server
374523090163466305   my-test-db           admin

Is this article helpful? 

Tell Fauna how the article can be improved:
Visit Fauna's forums or email docs@fauna.com

Thank you for your feedback!