Skip to main content


foo-api CLI is a Node.js package to provide utilities using Foo's REST API. This package is hosted on NPM.

Getting Started#

Follow the steps in getting started and make sure you have an API token as outlined in that section. You will use this token to populate FOO_API_TOKEN environment variable.

Install the CLI. This example installs globally.

npm install @foo-software/foo-api-cli -g

To see the version of the CLI you can use the v option as below.

foo-api --v


Below is the format for the CLI. Note the dependency on environment variables.

foo-api [command] [resource] [options]

Example Usage#

In the below example we use the import command to import pages to Foo from a CSV file.

FOO_API_TOKEN=abc123 \
foo-api import pages \
--file-path ./input/pages.csv \
--file-path-output ./output/pages.csv

If you've set FOO_API_TOKEN environment variable separately, it would simply be the below.

foo-api import pages \
--file-path ./input/pages.csv \
--file-path-output ./output/pages.csv

Boolean options can have a false value, or no value to represent a true value. Below shows how we use the silent boolean option.

foo-api import pages \
--file-path ./input/pages.csv \

Global Options#

The below options are available for all commands.



The silent options will supress all output entirely.



With batch operations, the CLI will throw an error if one occurs at the time it occurs. For example, the import command will import line by line from the specified CSV file. By default, if an error occurs, the CLI will store any error, and continue on - outputting all errors in the end. if fail-on-error is set, then the CLI will not continue and throw an error as soon as one occurs.



Imports pages to Foo from a CSV file.

import: Example#

foo-api import pages \
--file-path ./input/pages.csv

import: Resources#

import: Options#



The CSV file path relative to the CLI executor, for example: ./input/pages.csv. When importing pages, the format of the CSV is important and must follow the below example format (name, url).

Foo Home Page,



A CSV file path relative to the CLI executor that the CLI will output the result to, for example: ./output/pages.csv. When importing pages, the CLI will create an output similar to the following (id, name, url).

def456,Foo Home Page,

Environment Variables#



Follow the steps in getting started to acquire an API token and populate FOO_API_TOKEN environment variable with it. This is required for API authentication.