ورود | ثبت نام
  • FA
  • EN

API Docs

POST /api/v1/media

Attach a media file to a specified element (e.g., gym, post, user).


Permissions

You must have update permission for the target attachable resource.


Request Body Parameters

NameTypeRequiredDescriptionExample
attachable_typestringYesType of the element to attach media to (see below)"gym"
attachable_idintYesID of the element42
filefileYesThe media file to upload(binary file)
purposestringNoMarks the upload as a sensitive document instead of ordinary gallery media (see below)"gym_license"

Available purpose values:

ValueAttachableMeaning
trainer_licenseuserThe uploader's own trainer license. May only be attached to your own user record.
gym_licensegymThe gym's business license. May only be attached to a gym you are allowed to update.

Sensitive media. A media row with a purpose is never publicly downloadable — GET /api/v1/media/{media}/{filename} applies per-purpose access control to it, and it is excluded from the owning record's public media array. Uploading a license also points the owning record's *_license_image at the new file, deletes the superseded document, and resets *_license_approved to null (pending), because a new document has to be reviewed again — this applies to both trainer_license (on the user) and gym_license (on the gym). Omitting purpose (or sending null) uploads ordinary, publicly readable gallery media.

Available attachable_type values:

  • championship
  • gym
  • gym_equipment
  • post
  • user
  • education
  • gym_buffet_item
  • training_service
  • tracker_meal

Request Example (multipart/form-data)

POST /api/v1/media
Authorization: Bearer {token}
Content-Type: multipart/form-data

attachable_type=gym
attachable_id=42
file=@photo.jpg

Response

200 OK

Returns the created media resource.

Example

{
  "data": { /* media resource */ }
}

For a full schema, see Media Resource.


Error Responses

StatusDescriptionReference
422Validation errorValidation error
401UnauthorizedAuthentication error
403Forbidden (no permission)Permission error
Dambel

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

LinkedinInstagramXYoutubeTelegramGitHub