dambel

دمبل

shevron
ورود | ثبت نام

API Docs / comments / create



POST /api/v1/comments

Creates a new comment on a specified resource (e.g., gym, post, or training service).


Permissions

PermissionDescription
comments.createCreate comments as the authenticated user
view (commentable)Must have view permission on the target resource

Request Parameters

NameTypeRequiredDescriptionExample
commentable_typestringYesType of the resource to comment on. One of: gym, post, trainingService"gym"
commentable_idintYesID of the resource to comment on42
contentstringYesContent of the comment (max 255 characters)"Great gym!"
parent_comment_idintNoID of the parent comment (for replies)10

Request Example

{
  "commentable_type": "gym",
  "commentable_id": 42,
  "content": "Great gym!",
  "parent_comment_id": 10
}

Response

201 Created

Returns the created comment resource.

Schema

{
  "comment": { /* Comment Resource */ }
}

Example

{
  "comment": {
    "id": 123,
    "user_id": 456,
    "commentable_type": "App\\Models\\Gyms\\Gym",
    "commentable_id": 42,
    "content": "Great gym!",
    "parent_comment_id": 10,
    "created_at": "2025-01-01 00:00:00",
    "updated_at": "2025-01-01 00:03:00"
  }
}

For a full schema, see Comment Resource.


Error Responses

StatusDescriptionReference
422Validation errorValidation error
401UnauthorizedAuthentication error
403Forbidden (no permission)Permission error
footer wave
logo

دمبل، دنیای هوشمند ورزش و تغذیه

LinkedinInstagramXYoutube