---
# System prepended metadata

title: Using Textile for remote Thread services

---

Using Textile for remote Thread services
=========

## Run Textile cloud

`go run cmd/textiled/*.go --emailApiKey="<TOKEN>" --emailFrom="Textile <dev@email.textile.io>" --addrFilecoinApi=""`

## Install textile cli

```
go build -o textile-cli cmd/textile/*.go
chmod +x textile-cli
mv textile-cli /usr/local/bin/textile
```

## Setup a Textile project

### Run all commands against local cloud

Run this in any terminal session

`export TXTL_API_TARGET=127.0.0.1:3006`

### Login to Textile

```
admin@~/Textile/turing$ textile login
Enter your email: admin@tapir.app█
> We sent an email to admin@tapir.app. Please follow the steps provided inside it.
⠙ Waiting for your confirmation
```

After you complete the confirmation, your terminal should let you know the login was a success.

```
✔ Email confirmed
> Success! You are now logged in. Initialize a new project directory with `textile init`.
```

### Create a project

Create a project from scratch in your current directory.

```
admin@~/Textile/turing$ textile init
> Success! Initialized empty project in /Users/admin/Textile/turing/.textile
```

### Create an app token

Check your existing app tokens for the project

```
andrewhill@~/Textile/turing$ textile tokens ls
> Selected turing
> Found 0 tokens
```

Create a new token in the current project

```
andrewhill@~/Textile/turing$ textile tokens add
> Selected turing
> Success! Added new app token 132ccf89-0e99-4bfa-81d1-333f92b72c2e
```

This token now gives you the ability to use project resources (storage, request APIs, gateways, and Thread services from apps you build). 

## Create an app session

Use an API testing tool. [Postman](https://www.postman.com/) works well, or curl.

#### Create the post payload to cloud

Create a `POST` request to `http://127.0.0.1:8006/register`

Include a `raw` post body containing

```
{
"token": "<APP TOKEN>",
"device_id": "77b7b712-5ec4-42f2-b3c4-58b22f0cf057"
}
```

where `token` is from above, and `device_id` is a uuid
(try using `uuidgen` on *nix systems).

Submit the request. The response should look something like,

```
{
    "id": "77b7b712-5ec4-42f2-b3c4-58b22f0cf057",
    "session_id": "7a251dfc-9258-4bf8-84fe-b551cc089a58"
}
```

You can also use curl with something like,

```
curl -H "Content-Type: application/json" --data @req.json http://127.0.0.1:8006/register
```

where `req.json` is a JSON file with the above `token` and
`device_id` info.

