Overview
POST
/friends/requestsfriendsSend a friend request (idempotent on the unordered pair; mutual → auto-accept)
Creates a pending friendship with the caller as requester. If an edge for the unordered pair already exists in either direction no second row is created: a pending request FROM the other user is auto-accepted (both sides asked), a pending request from the caller or an accepted friendship is returned as-is, and a declined edge flips back to pending with the caller as requester. Refused (403) while a block exists in either direction between the two users.
Auth: bearerAuth — calls run as the authenticated user.
Request body
application/json · optional
- userIdstring
The customer id of the user to befriend
Example
{
"userId": "string"
}Responses
200
The existing (or auto-accepted / re-requested) friendship
- idstring
- ecosystemIdstring
- requesterIdstring
- addresseeIdstring
- status"pending" | "accepted" | "declined"
- createdAtstring
- updatedAtstring
Example
{
"id": "string",
"ecosystemId": "string",
"requesterId": "string",
"addresseeId": "string",
"status": "pending",
"createdAt": "string",
"updatedAt": "string"
}201
The created pending friendship
- idstring
- ecosystemIdstring
- requesterIdstring
- addresseeIdstring
- status"pending" | "accepted" | "declined"
- createdAtstring
- updatedAtstring
Example
{
"id": "string",
"ecosystemId": "string",
"requesterId": "string",
"addresseeId": "string",
"status": "pending",
"createdAt": "string",
"updatedAt": "string"
}400
Error
- erroroptionalobject
Example
{
"error": {
"message": "string",
"code": "string"
}
}401
Error
- erroroptionalobject
Example
{
"error": {
"message": "string",
"code": "string"
}
}403
Error
- erroroptionalobject
Example
{
"error": {
"message": "string",
"code": "string"
}
}404
Error
- erroroptionalobject
Example
{
"error": {
"message": "string",
"code": "string"
}
}409
Error
- erroroptionalobject
Example
{
"error": {
"message": "string",
"code": "string"
}
}Code examples
cURL
curl -X POST "https://api.agenticdeveloperhub.com/friends/requests" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"userId": "string"
}'JavaScript
const res = await fetch("https://api.agenticdeveloperhub.com/friends/requests", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json"
},
body: "{\n \"userId\": \"string\"\n}",
});
const data = await res.json();