mirror of
https://github.com/netbirdio/docs.git
synced 2026-05-05 08:46:37 +00:00
load api subendpoints
This commit is contained in:
36
src/pages/ipa/guides/authentication.mdx
Normal file
36
src/pages/ipa/guides/authentication.mdx
Normal file
@@ -0,0 +1,36 @@
|
||||
import {HeroPattern} from "@/components/HeroPattern";
|
||||
export const description =
|
||||
'In this guide, we’ll look at how authentication works. NetBird offers two ways to authenticate your API requests: OAuth2 and personal access tokens.'
|
||||
|
||||
<HeroPattern/>
|
||||
|
||||
# Authentication
|
||||
|
||||
You'll need to authenticate your requests to access any of the endpoints in the NetBird API. In this guide, we'll look at how authentication works. Netbird offers two ways to authenticate your API requests: OAuth2 and personal access tokens (PAT). {{ className: 'lead' }}
|
||||
|
||||
## OAuth2 with bearer token
|
||||
|
||||
When establishing a connection using OAuth2, you will need your access token — you can retrieve one from your IDP manager. Here's how to add the token to the request header using cURL:
|
||||
|
||||
```bash {{ title: 'Example request with bearer token' }}
|
||||
curl https://api.netbird.io/api/users \
|
||||
-H "Authorization: Bearer {token}"
|
||||
```
|
||||
|
||||
Always keep your token safe and reset it if you suspect it has been compromised.
|
||||
|
||||
## Using personal access tokens
|
||||
|
||||
When establishing a connection using [PATs](/docs/how-netbird-works#personal-access-tokens), you will need your access token — you can create one in the [Netbird dashboard](#) under User settings. It is recommended to use [service users](/docs/how-netbird-works#service-users) for all organization wide flows calling the API. Here's how to add the token to the request header using cURL:
|
||||
|
||||
```bash {{ title: 'Example request with personal access token' }}
|
||||
curl https://api.netbird.io/api/users \
|
||||
-H "Authorization: Token {token}"
|
||||
```
|
||||
|
||||
Always keep your token safe and reset it if you suspect it has been compromised.
|
||||
|
||||
<div className="not-prose mb-16 mt-6 flex gap-3">
|
||||
<Button href="/docs/how-netbird-works#personal-access-tokens" arrow="right" children="How to create tokens" />
|
||||
</div>
|
||||
|
||||
36
src/pages/ipa/guides/errors.mdx
Normal file
36
src/pages/ipa/guides/errors.mdx
Normal file
@@ -0,0 +1,36 @@
|
||||
import {HeroPattern} from "@/components/HeroPattern"; import {Note} from "@/components/mdx";
|
||||
export const description =
|
||||
'In this guide, we will talk about what happens when something goes wrong while you work with the API.'
|
||||
|
||||
<HeroPattern/>
|
||||
|
||||
# Errors
|
||||
|
||||
When working with APIs, it's important to understand the different types of HTTP errors that you might encounter. These errors can help you diagnose issues with your API requests and determine how to resolve them. {{ className: 'lead' }}
|
||||
|
||||
You can tell if your request was successful by checking the status code when receiving an API response. If a response comes back unsuccessful, you can use the error type and error message to figure out what has gone wrong and do some rudimentary debugging.
|
||||
|
||||
<Note>
|
||||
The API is still in Beta state so some errors might not be handled properly yet.
|
||||
</Note>
|
||||
|
||||
---
|
||||
|
||||
## Status codes
|
||||
|
||||
Here is a list of the different categories of status codes returned by the NetBird API. Use these to understand if a request was successful.
|
||||
|
||||
<Properties>
|
||||
<Property name="2xx">
|
||||
A 2xx status code indicates a successful response.
|
||||
</Property>
|
||||
<Property name="4xx">
|
||||
A 4xx status code indicates a client error - those are mostly related to missing permissions or invalid parameters inside the request.
|
||||
</Property>
|
||||
<Property name="5xx">
|
||||
A 5xx status code indicates a server error - in this case please reach out to us via [Slack](https://join.slack.com/t/netbirdio/shared_invite/zt-vrahf41g-ik1v7fV8du6t0RwxSrJ96A) or [GitHub](https://github.com/netbirdio/netbird/issues).
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
---
|
||||
|
||||
50
src/pages/ipa/guides/quickstart.mdx
Normal file
50
src/pages/ipa/guides/quickstart.mdx
Normal file
@@ -0,0 +1,50 @@
|
||||
import {HeroPattern} from "@/components/HeroPattern";
|
||||
export const description =
|
||||
'This guide will get you all set up and ready to use the NetBird API. We’ll cover how to get started and how to make your first API request.'
|
||||
|
||||
<HeroPattern/>
|
||||
|
||||
# Quickstart
|
||||
|
||||
This guide will get you all set up and ready to use the NetBird API. We'll cover how to get started using cURL and how to make your first API request. We'll also look at where to go next to find all the information you need to take full advantage of our powerful REST API. {{ className: 'lead' }}
|
||||
|
||||
## Install cURL
|
||||
|
||||
For this guide, we'll be using cURL to make our first API request. If you don't already have cURL installed, you can download it from the [cURL website](https://curl.se/download.html).
|
||||
|
||||
## Get an access token
|
||||
|
||||
Before making your first API request, you need to create an access token to authenticate requests to the API. You can create an access token in the [Netbird dashboard](https://app.netbird.io) under [Users » Me](https://app.netbird.io/users).
|
||||
After the token was created successfully make sure to store it as we need it for the next step.
|
||||
|
||||
## Making your first API request
|
||||
|
||||
After creating your access token, you are ready to make your first call to the NetBird API. Below, you can see how to send a GET request to the peers endpoint to get a list of all peers in your network.
|
||||
|
||||
<CodeGroup tag="GET" label="/api/peers">
|
||||
|
||||
```bash {{ title: 'cURL' }}
|
||||
curl -X GET https://api.netbird.io/api/peers \
|
||||
-H 'Accept: application/json' \
|
||||
-H 'Authorization: Token <TOKEN>'
|
||||
```
|
||||
|
||||
</CodeGroup>
|
||||
|
||||
<div className="not-prose">
|
||||
<Button
|
||||
href="/peers"
|
||||
variant="text"
|
||||
arrow="right"
|
||||
children="Read the docs for the peers endpoint"
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
## What's next?
|
||||
|
||||
Great, you're now set up with an API client and have made your first request to the API. Here are a few links that might be handy as you venture further into the NetBird API:
|
||||
|
||||
- [Read how to properly authenticate against the NetBird API](/authentication)
|
||||
- [Check out the users endpoint](/users)
|
||||
- [Learn about the different error types](/errors)
|
||||
Reference in New Issue
Block a user