Files
seedPass/landing/docs/api_reference.html
2025-07-09 22:08:31 -04:00

321 lines
25 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>api_reference</title>
<style>
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
div.columns{display: flex; gap: min(4vw, 1.5em);}
div.column{flex: auto; overflow-x: auto;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
/* The extra [class] is a hack that increases specificity enough to
override a similar rule in reveal.js */
ul.task-list[class]{list-style: none;}
ul.task-list li input[type="checkbox"] {
font-size: inherit;
width: 0.8em;
margin: 0 0.8em 0.2em -1.6em;
vertical-align: middle;
}
.display.math{display: block; text-align: center; margin: 0.5rem auto;}
/* CSS for syntax highlighting */
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
div.sourceCode { margin: 1em 0; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
{ counter-reset: source-line 0; }
pre.numberSource code > span
{ position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
{ content: counter(source-line);
position: relative; left: -1em; text-align: right; vertical-align: baseline;
border: none; display: inline-block;
-webkit-touch-callout: none; -webkit-user-select: none;
-khtml-user-select: none; -moz-user-select: none;
-ms-user-select: none; user-select: none;
padding: 0 4px; width: 4em;
color: #aaaaaa;
}
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; }
div.sourceCode
{ }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
code span.al { color: #ff0000; font-weight: bold; } /* Alert */
code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
code span.at { color: #7d9029; } /* Attribute */
code span.bn { color: #40a070; } /* BaseN */
code span.bu { color: #008000; } /* BuiltIn */
code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
code span.ch { color: #4070a0; } /* Char */
code span.cn { color: #880000; } /* Constant */
code span.co { color: #60a0b0; font-style: italic; } /* Comment */
code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
code span.do { color: #ba2121; font-style: italic; } /* Documentation */
code span.dt { color: #902000; } /* DataType */
code span.dv { color: #40a070; } /* DecVal */
code span.er { color: #ff0000; font-weight: bold; } /* Error */
code span.ex { } /* Extension */
code span.fl { color: #40a070; } /* Float */
code span.fu { color: #06287e; } /* Function */
code span.im { color: #008000; font-weight: bold; } /* Import */
code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
code span.kw { color: #007020; font-weight: bold; } /* Keyword */
code span.op { color: #666666; } /* Operator */
code span.ot { color: #007020; } /* Other */
code span.pp { color: #bc7a00; } /* Preprocessor */
code span.sc { color: #4070a0; } /* SpecialChar */
code span.ss { color: #bb6688; } /* SpecialString */
code span.st { color: #4070a0; } /* String */
code span.va { color: #19177c; } /* Variable */
code span.vs { color: #4070a0; } /* VerbatimString */
code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
</style>
<link rel="stylesheet" href="theme.css" />
</head>
<body>
<h1 id="seedpass-rest-api-reference">SeedPass REST API Reference</h1>
<p>This guide covers how to start the SeedPass API, authenticate
requests, and interact with the available endpoints.</p>
<h2 id="starting-the-api">Starting the API</h2>
<p>Run <code>seedpass api start</code> from your terminal. The command
prints a onetime token used for authentication:</p>
<div class="sourceCode" id="cb1"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="ex">$</span> seedpass api start</span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="ex">API</span> token: abcdef1234567890</span></code></pre></div>
<p>Keep this token secret. Every request must include it in the
<code>Authorization</code> header using the <code>Bearer</code>
scheme.</p>
<h2 id="endpoints">Endpoints</h2>
<ul>
<li><code>GET /api/v1/entry?query=&lt;text&gt;</code> Search entries
matching a query.</li>
<li><code>GET /api/v1/entry/{id}</code> Retrieve a single entry by its
index.</li>
<li><code>POST /api/v1/entry</code> Create a new entry of any
supported type.</li>
<li><code>PUT /api/v1/entry/{id}</code> Modify an existing entry.</li>
<li><code>PUT /api/v1/config/{key}</code> Update a configuration
value.</li>
<li><code>POST /api/v1/secret-mode</code> Enable or disable Secret
Mode and set the clipboard delay.</li>
<li><code>POST /api/v1/entry/{id}/archive</code> Archive an
entry.</li>
<li><code>POST /api/v1/entry/{id}/unarchive</code> Unarchive an
entry.</li>
<li><code>GET /api/v1/config/{key}</code> Return the value for a
configuration key.</li>
<li><code>GET /api/v1/fingerprint</code> List available seed
fingerprints.</li>
<li><code>POST /api/v1/fingerprint</code> Add a new seed
fingerprint.</li>
<li><code>DELETE /api/v1/fingerprint/{fp}</code> Remove a
fingerprint.</li>
<li><code>POST /api/v1/fingerprint/select</code> Switch the active
fingerprint.</li>
<li><code>GET /api/v1/totp/export</code> Export all TOTP entries as
JSON.</li>
<li><code>GET /api/v1/totp</code> Return current TOTP codes and
remaining time.</li>
<li><code>GET /api/v1/stats</code> Return statistics about the active
seed profile.</li>
<li><code>GET /api/v1/parent-seed</code> Reveal the parent seed or
save it with <code>?file=</code>.</li>
<li><code>GET /api/v1/nostr/pubkey</code> Fetch the Nostr public key
for the active seed.</li>
<li><code>POST /api/v1/checksum/verify</code> Verify the checksum of
the running script.</li>
<li><code>POST /api/v1/checksum/update</code> Update the stored script
checksum.</li>
<li><code>POST /api/v1/change-password</code> Change the master
password for the active profile.</li>
<li><code>POST /api/v1/vault/import</code> Import a vault backup from
a file or path.</li>
<li><code>POST /api/v1/vault/export</code> Export the vault and
download the encrypted file.</li>
<li><code>POST /api/v1/vault/backup-parent-seed</code> Save an
encrypted backup of the parent seed.</li>
<li><code>POST /api/v1/vault/lock</code> Lock the vault and clear
sensitive data from memory.</li>
<li><code>GET /api/v1/relays</code> List configured Nostr relays.</li>
<li><code>POST /api/v1/relays</code> Add a relay URL.</li>
<li><code>DELETE /api/v1/relays/{idx}</code> Remove the relay at the
given index (1based).</li>
<li><code>POST /api/v1/relays/reset</code> Reset the relay list to
defaults.</li>
<li><code>POST /api/v1/shutdown</code> Stop the server
gracefully.</li>
</ul>
<p><strong>Security Warning:</strong> Accessing
<code>/api/v1/parent-seed</code> exposes your master seed in plain text.
Use it only from a trusted environment.</p>
<h2 id="example-requests">Example Requests</h2>
<p>Send requests with the token in the header:</p>
<div class="sourceCode" id="cb2"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="ex">curl</span> <span class="at">-H</span> <span class="st">&quot;Authorization: Bearer &lt;token&gt;&quot;</span> <span class="dt">\</span></span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a> <span class="st">&quot;http://127.0.0.1:8000/api/v1/entry?query=email&quot;</span></span></code></pre></div>
<h3 id="creating-an-entry">Creating an Entry</h3>
<p><code>POST /api/v1/entry</code> accepts a JSON body with at least a
<code>label</code> field. Set <code>type</code> (or <code>kind</code>)
to choose the entry variant (<code>password</code>, <code>totp</code>,
<code>ssh</code>, <code>pgp</code>, <code>nostr</code>,
<code>seed</code>, <code>key_value</code>, or
<code>managed_account</code>). Additional fields vary by type:</p>
<ul>
<li><strong>password</strong> <code>length</code>, optional
<code>username</code>, <code>url</code> and <code>notes</code></li>
<li><strong>totp</strong> <code>secret</code> or <code>index</code>,
optional <code>period</code>, <code>digits</code>, <code>notes</code>,
<code>archived</code></li>
<li><strong>ssh/nostr/seed/managed_account</strong>
<code>index</code>, optional <code>notes</code>,
<code>archived</code></li>
<li><strong>pgp</strong> <code>index</code>, <code>key_type</code>,
<code>user_id</code>, optional <code>notes</code>,
<code>archived</code></li>
<li><strong>key_value</strong> <code>value</code>, optional
<code>notes</code></li>
</ul>
<p>Example creating a TOTP entry:</p>
<div class="sourceCode" id="cb3"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="ex">curl</span> <span class="at">-X</span> POST http://127.0.0.1:8000/api/v1/entry <span class="dt">\</span></span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a> <span class="at">-H</span> <span class="st">&quot;Authorization: Bearer &lt;token&gt;&quot;</span> <span class="dt">\</span></span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a> <span class="at">-H</span> <span class="st">&quot;Content-Type: application/json&quot;</span> <span class="dt">\</span></span>
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a> <span class="at">-d</span> <span class="st">&#39;{&quot;type&quot;: &quot;totp&quot;, &quot;label&quot;: &quot;Email&quot;, &quot;secret&quot;: &quot;JBSW...&quot;}&#39;</span></span></code></pre></div>
<h3 id="updating-an-entry">Updating an Entry</h3>
<p>Use <code>PUT /api/v1/entry/{id}</code> to change fields such as
<code>label</code>, <code>username</code>, <code>url</code>,
<code>notes</code>, <code>period</code>, <code>digits</code> or
<code>value</code> depending on the entry type.</p>
<div class="sourceCode" id="cb4"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="ex">curl</span> <span class="at">-X</span> PUT http://127.0.0.1:8000/api/v1/entry/1 <span class="dt">\</span></span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a> <span class="at">-H</span> <span class="st">&quot;Authorization: Bearer &lt;token&gt;&quot;</span> <span class="dt">\</span></span>
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a> <span class="at">-H</span> <span class="st">&quot;Content-Type: application/json&quot;</span> <span class="dt">\</span></span>
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a> <span class="at">-d</span> <span class="st">&#39;{&quot;username&quot;: &quot;alice&quot;}&#39;</span></span></code></pre></div>
<h3 id="updating-configuration">Updating Configuration</h3>
<p>Send a JSON body containing a <code>value</code> field to
<code>PUT /api/v1/config/{key}</code>:</p>
<div class="sourceCode" id="cb5"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="ex">curl</span> <span class="at">-X</span> PUT http://127.0.0.1:8000/api/v1/config/inactivity_timeout <span class="dt">\</span></span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a> <span class="at">-H</span> <span class="st">&quot;Authorization: Bearer &lt;token&gt;&quot;</span> <span class="dt">\</span></span>
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a> <span class="at">-H</span> <span class="st">&quot;Content-Type: application/json&quot;</span> <span class="dt">\</span></span>
<span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a> <span class="at">-d</span> <span class="st">&#39;{&quot;value&quot;: 300}&#39;</span></span></code></pre></div>
<h3 id="toggling-secret-mode">Toggling Secret Mode</h3>
<p>Send both <code>enabled</code> and <code>delay</code> values to
<code>/api/v1/secret-mode</code>:</p>
<div class="sourceCode" id="cb6"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="ex">curl</span> <span class="at">-X</span> POST http://127.0.0.1:8000/api/v1/secret-mode <span class="dt">\</span></span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a> <span class="at">-H</span> <span class="st">&quot;Authorization: Bearer &lt;token&gt;&quot;</span> <span class="dt">\</span></span>
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a> <span class="at">-H</span> <span class="st">&quot;Content-Type: application/json&quot;</span> <span class="dt">\</span></span>
<span id="cb6-4"><a href="#cb6-4" aria-hidden="true" tabindex="-1"></a> <span class="at">-d</span> <span class="st">&#39;{&quot;enabled&quot;: true, &quot;delay&quot;: 20}&#39;</span></span></code></pre></div>
<h3 id="switching-fingerprints">Switching Fingerprints</h3>
<p>Change the active seed profile via
<code>POST /api/v1/fingerprint/select</code>:</p>
<div class="sourceCode" id="cb7"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="ex">curl</span> <span class="at">-X</span> POST http://127.0.0.1:8000/api/v1/fingerprint/select <span class="dt">\</span></span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a> <span class="at">-H</span> <span class="st">&quot;Authorization: Bearer &lt;token&gt;&quot;</span> <span class="dt">\</span></span>
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a> <span class="at">-H</span> <span class="st">&quot;Content-Type: application/json&quot;</span> <span class="dt">\</span></span>
<span id="cb7-4"><a href="#cb7-4" aria-hidden="true" tabindex="-1"></a> <span class="at">-d</span> <span class="st">&#39;{&quot;fingerprint&quot;: &quot;abc123&quot;}&#39;</span></span></code></pre></div>
<h3 id="exporting-the-vault">Exporting the Vault</h3>
<p>Download an encrypted vault backup via
<code>POST /api/v1/vault/export</code>:</p>
<div class="sourceCode" id="cb8"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="ex">curl</span> <span class="at">-X</span> POST http://127.0.0.1:8000/api/v1/vault/export <span class="dt">\</span></span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a> <span class="at">-H</span> <span class="st">&quot;Authorization: Bearer &lt;token&gt;&quot;</span> <span class="dt">\</span></span>
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a> <span class="at">-o</span> backup.json</span></code></pre></div>
<h3 id="importing-a-vault">Importing a Vault</h3>
<p>Restore a backup with <code>POST /api/v1/vault/import</code>. Use
<code>-F</code> to upload a file:</p>
<div class="sourceCode" id="cb9"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a><span class="ex">curl</span> <span class="at">-X</span> POST http://127.0.0.1:8000/api/v1/vault/import <span class="dt">\</span></span>
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a> <span class="at">-H</span> <span class="st">&quot;Authorization: Bearer &lt;token&gt;&quot;</span> <span class="dt">\</span></span>
<span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a> <span class="at">-F</span> file=@backup.json</span></code></pre></div>
<h3 id="locking-the-vault">Locking the Vault</h3>
<p>Clear sensitive data from memory using
<code>/api/v1/vault/lock</code>:</p>
<div class="sourceCode" id="cb10"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a><span class="ex">curl</span> <span class="at">-X</span> POST http://127.0.0.1:8000/api/v1/vault/lock <span class="dt">\</span></span>
<span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a> <span class="at">-H</span> <span class="st">&quot;Authorization: Bearer &lt;token&gt;&quot;</span></span></code></pre></div>
<h3 id="backing-up-the-parent-seed">Backing Up the Parent Seed</h3>
<p>Trigger an encrypted seed backup with
<code>/api/v1/vault/backup-parent-seed</code>:</p>
<div class="sourceCode" id="cb11"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a><span class="ex">curl</span> <span class="at">-X</span> POST http://127.0.0.1:8000/api/v1/vault/backup-parent-seed <span class="dt">\</span></span>
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a> <span class="at">-H</span> <span class="st">&quot;Authorization: Bearer &lt;token&gt;&quot;</span> <span class="dt">\</span></span>
<span id="cb11-3"><a href="#cb11-3" aria-hidden="true" tabindex="-1"></a> <span class="at">-H</span> <span class="st">&quot;Content-Type: application/json&quot;</span> <span class="dt">\</span></span>
<span id="cb11-4"><a href="#cb11-4" aria-hidden="true" tabindex="-1"></a> <span class="at">-d</span> <span class="st">&#39;{&quot;path&quot;: &quot;seed_backup.enc&quot;}&#39;</span></span></code></pre></div>
<h3 id="retrieving-vault-statistics">Retrieving Vault Statistics</h3>
<p>Get profile stats such as entry counts with
<code>GET /api/v1/stats</code>:</p>
<div class="sourceCode" id="cb12"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a><span class="ex">curl</span> <span class="at">-H</span> <span class="st">&quot;Authorization: Bearer &lt;token&gt;&quot;</span> <span class="dt">\</span></span>
<span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a> http://127.0.0.1:8000/api/v1/stats</span></code></pre></div>
<h3 id="changing-the-master-password">Changing the Master Password</h3>
<p>Update the vault password via
<code>POST /api/v1/change-password</code>:</p>
<div class="sourceCode" id="cb13"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a><span class="ex">curl</span> <span class="at">-X</span> POST http://127.0.0.1:8000/api/v1/change-password <span class="dt">\</span></span>
<span id="cb13-2"><a href="#cb13-2" aria-hidden="true" tabindex="-1"></a> <span class="at">-H</span> <span class="st">&quot;Authorization: Bearer &lt;token&gt;&quot;</span></span></code></pre></div>
<h3 id="verifying-the-script-checksum">Verifying the Script
Checksum</h3>
<p>Check that the running script matches the stored checksum:</p>
<div class="sourceCode" id="cb14"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a><span class="ex">curl</span> <span class="at">-X</span> POST http://127.0.0.1:8000/api/v1/checksum/verify <span class="dt">\</span></span>
<span id="cb14-2"><a href="#cb14-2" aria-hidden="true" tabindex="-1"></a> <span class="at">-H</span> <span class="st">&quot;Authorization: Bearer &lt;token&gt;&quot;</span></span></code></pre></div>
<h3 id="updating-the-script-checksum">Updating the Script Checksum</h3>
<p>Regenerate the stored checksum using
<code>/api/v1/checksum/update</code>:</p>
<div class="sourceCode" id="cb15"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a><span class="ex">curl</span> <span class="at">-X</span> POST http://127.0.0.1:8000/api/v1/checksum/update <span class="dt">\</span></span>
<span id="cb15-2"><a href="#cb15-2" aria-hidden="true" tabindex="-1"></a> <span class="at">-H</span> <span class="st">&quot;Authorization: Bearer &lt;token&gt;&quot;</span></span></code></pre></div>
<h3 id="managing-relays">Managing Relays</h3>
<p>List, add, or remove Nostr relays:</p>
<div class="sourceCode" id="cb16"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb16-1"><a href="#cb16-1" aria-hidden="true" tabindex="-1"></a><span class="co"># list</span></span>
<span id="cb16-2"><a href="#cb16-2" aria-hidden="true" tabindex="-1"></a><span class="ex">curl</span> <span class="at">-H</span> <span class="st">&quot;Authorization: Bearer &lt;token&gt;&quot;</span> http://127.0.0.1:8000/api/v1/relays</span>
<span id="cb16-3"><a href="#cb16-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb16-4"><a href="#cb16-4" aria-hidden="true" tabindex="-1"></a><span class="co"># add</span></span>
<span id="cb16-5"><a href="#cb16-5" aria-hidden="true" tabindex="-1"></a><span class="ex">curl</span> <span class="at">-X</span> POST http://127.0.0.1:8000/api/v1/relays <span class="dt">\</span></span>
<span id="cb16-6"><a href="#cb16-6" aria-hidden="true" tabindex="-1"></a> <span class="at">-H</span> <span class="st">&quot;Authorization: Bearer &lt;token&gt;&quot;</span> <span class="dt">\</span></span>
<span id="cb16-7"><a href="#cb16-7" aria-hidden="true" tabindex="-1"></a> <span class="at">-H</span> <span class="st">&quot;Content-Type: application/json&quot;</span> <span class="dt">\</span></span>
<span id="cb16-8"><a href="#cb16-8" aria-hidden="true" tabindex="-1"></a> <span class="at">-d</span> <span class="st">&#39;{&quot;url&quot;: &quot;wss://relay.example.com&quot;}&#39;</span></span>
<span id="cb16-9"><a href="#cb16-9" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb16-10"><a href="#cb16-10" aria-hidden="true" tabindex="-1"></a><span class="co"># remove first relay</span></span>
<span id="cb16-11"><a href="#cb16-11" aria-hidden="true" tabindex="-1"></a><span class="ex">curl</span> <span class="at">-X</span> DELETE http://127.0.0.1:8000/api/v1/relays/1 <span class="dt">\</span></span>
<span id="cb16-12"><a href="#cb16-12" aria-hidden="true" tabindex="-1"></a> <span class="at">-H</span> <span class="st">&quot;Authorization: Bearer &lt;token&gt;&quot;</span></span>
<span id="cb16-13"><a href="#cb16-13" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb16-14"><a href="#cb16-14" aria-hidden="true" tabindex="-1"></a><span class="co"># reset to defaults</span></span>
<span id="cb16-15"><a href="#cb16-15" aria-hidden="true" tabindex="-1"></a><span class="ex">curl</span> <span class="at">-X</span> POST http://127.0.0.1:8000/api/v1/relays/reset <span class="dt">\</span></span>
<span id="cb16-16"><a href="#cb16-16" aria-hidden="true" tabindex="-1"></a> <span class="at">-H</span> <span class="st">&quot;Authorization: Bearer &lt;token&gt;&quot;</span></span></code></pre></div>
<h3 id="enabling-cors">Enabling CORS</h3>
<p>Crossorigin requests are disabled by default. Set
<code>SEEDPASS_CORS_ORIGINS</code> to a commaseparated list of allowed
origins before starting the API:</p>
<div class="sourceCode" id="cb17"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true" tabindex="-1"></a><span class="va">SEEDPASS_CORS_ORIGINS</span><span class="op">=</span>http://localhost:3000 <span class="ex">seedpass</span> api start</span></code></pre></div>
<p>Browsers can then call the API from the specified origins, for
example using JavaScript:</p>
<div class="sourceCode" id="cb18"><pre
class="sourceCode javascript"><code class="sourceCode javascript"><span id="cb18-1"><a href="#cb18-1" aria-hidden="true" tabindex="-1"></a><span class="fu">fetch</span>(<span class="st">&#39;http://127.0.0.1:8000/api/v1/entry?query=email&#39;</span><span class="op">,</span> {</span>
<span id="cb18-2"><a href="#cb18-2" aria-hidden="true" tabindex="-1"></a> <span class="dt">headers</span><span class="op">:</span> { <span class="dt">Authorization</span><span class="op">:</span> <span class="st">&#39;Bearer &lt;token&gt;&#39;</span> }</span>
<span id="cb18-3"><a href="#cb18-3" aria-hidden="true" tabindex="-1"></a>})<span class="op">;</span></span></code></pre></div>
<p>Without CORS enabled, only sameorigin or commandline tools like
<code>curl</code> can access the API.</p>
</body>
</html>