This endpoint allows you to create a new linktree or update an existing one. If a linktree with the provided slug already exists, it will be updated.
POST /api/links{
"slug": "myblogroll", // Required: Unique identifier for the linktree
"title": "My Favorite Blogs", // Required: Title of the linktree
"description": "A collection of blogs I read regularly", // Optional: Description
"links": [ // Required: Array of links (at least one)
{
"title": "My Blog", // Required: Title of the link
"url": "https://myblog.com", // Required: URL of the link
"description": "My personal blog" // Optional: Description of the link
},
{
"title": "GitHub",
"url": "https://github.com/username"
}
]
}On success, the API returns the created or updated linktree:
{
"id": 1,
"slug": "myblogroll",
"title": "My Favorite Blogs",
"description": "A collection of blogs I read regularly",
"created_at": "2023-06-01T12:00:00.000Z",
"updated_at": "2023-06-01T12:00:00.000Z",
"links": [
{
"id": 1,
"title": "My Blog",
"url": "https://myblog.com",
"description": "My personal blog",
"position": 0
},
{
"id": 2,
"title": "GitHub",
"url": "https://github.com/username",
"description": null,
"position": 1
}
]
}The API may return the following error responses:
Using curl:
curl -X POST \
-H "Content-Type: application/json" \
-d '{
"slug": "myblogroll",
"title": "My Favorite Blogs",
"description": "A collection of blogs I read regularly",
"links": [
{
"title": "My Blog",
"url": "https://myblog.com",
"description": "My personal blog"
},
{
"title": "GitHub",
"url": "https://github.com/username"
}
]
}' \
https://yourdomain.com/api/linksAfter creating a linktree, you can access it at:https://yourdomain.com/c/{slug}
For example, the linktree created above would be accessible at:https://yourdomain.com/c/myblogroll