# Data Synchronisation

Your projects, snapshots etc. can all be sent up to the dashboard for better analysis. Whether you're running a Python script or a Jupyter notebook, you can easily link your project with your dashboard.

This is good if;

* You use different machines that don't share storage.
* You are creating results on a cloud system.
* You are creating results on multiple systems.
* You want to see your results centrally on the Etiq Dashboard.

### Creating Access Tokens

To do this, you need to log into the dashboard and create an "Access Token". This is a secret key used to submit content to the dashboard;

<figure><img src="/files/EWk7VPelsz5HySCxZLij" alt=""><figcaption><p>Click "Manage Access Tokens" in the menu</p></figcaption></figure>

<figure><img src="/files/H7rJ2h8DZdNCsSOBiuz2" alt=""><figcaption><p>Access Token Management Page</p></figcaption></figure>

1. Enter a useful name for the token in the "Token Name" box. This will help identify it later on when it comes to removing it.
2. Click "Add"
3. The token is created. Copy it safely to a file somewhere.

{% hint style="warning" %}
You can't come back to this page to view the full token. So be sure to copy the token somewhere!
{% endhint %}

### Using Access Tokens

Within your Python code, we should call this directly **before** we open any projects or snapshots;

```python
etiq.login("http://dashboard.example.org", "my-token-text")
```

We use the pair of "dashboard url" and "token text" to identify where and to whom the projects are sent. That is, the user which created the token will own projects created using this token.

From hereon, all records created will be synchronised with the dashboard until the script finishes or `etiq.logout()` is called.

{% hint style="danger" %}
Don't keep access tokens in source code!
{% endhint %}

For security reasons, and to aid in convenience if the token changes, you should either keep the auth key in a file and read that file at runtime;

```python
with open("key.txt") as f:
    etiq.login("https://dashboard.example.org", f.read().strip())
```

Or as an environment variable;

```python
import os
# These environment variables need to be set yourself outside the script!
etiq.login(os.environ["ETIQ_DASHBOARD_URL"], os.environ["ETIQ_TOKEN"])
```

If you log in above and you're in an interactive session, you'll be notified that the login was a success;

`'Connection successful. Projects and pipelines will be displayed in the dashboard. 😀'`

If this token is invalid, a traceback will be raised.

### Login Scope

You must login each session to continue persisting, it is only kept in memory.

If you want to stop sharing but have already logged in, calling `etiq.logout()` will "forget" the token and work will only be available locally.

### Accessing Existing Projects

You can also access projects that you've created previously or have been shared with you using the Python API;

```python
# Either you know what it's called:
project = etiq.projects.open("My Existing Project", create_if_missing=False)

# Or you can pick and choose:
all_projects = etiq.projects.get_all_projects()
```

Note the use of the parameter `create_if_missing` above. By default if you open a project and it's not there, we will just quietly create it for you. But if you know you want to add to an existing project, then it's best to use this so we can be sure we've got an existing project.

### Adding To Existing Shared Projects

When you have an existing project you can add snapshots to that as though it were your own. This way you can collaborate on projects with team members.

### Deleting Access Tokens

Simply click the "Delete" button within the token management page. Note that this makes the token invalid and will not work anymore. The `etiq.login` method will fail if we try to use it from this point onwards.


---

# 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://docs.etiq.ai/etiq-1.x-documentation/dashboard/data-synchronisation.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.
