Files API: Difference between modified_at and updated_at?

Jump to solution
LawsonJohnson
Community Member

I'm creating a solution to pull course files into another storage platform automatically and am attempting to avoid unnecessary downloads/writes. When consulting the docs (Files - Canvas LMS REST API Documentation), I noticed two fields: modified_at and updated_at. What is the difference between them, and what triggers their changes? I presume modified_at is related to the hosted file's metadata rather than the API file object (I see that Folder objects in the API have updated_at only), but I can't find anything to confirm this theory.

Can anyone here confirm which means what or point me to the documentation for this?

Labels (1)
0 Likes
1 Solution
James
Community Champion

@LawsonJohnson 

created_at and updated_at refer to the record in the database. modified_at refers to the file.

created_at is when the database record about the file was created.

updated_at is when the database record about the file was last modified. For example, if you rename the file it changes the updated_at timestamp, but not the modified_at timestamp. Similarly, publishing/unpublishing the file would change the record and thus the updated_at timestamp.

modified_at refers to when the file was last modified. This is the timestamp of when it was uploaded to Canvas, not when it was saved on the local disk or any information in the file's metadata. It would change if you uploaded a new version, replacing the existing version.

I verified this by renaming a file through the UI and noting that the updated_at was changed, but not the modified_at. I also verified that unpublishing a file changed the updated_at date.

For that particular file I was looking at, the modified_at was actually prior to the created_at. That makes sense because the file had to be successfully uploaded before the file object in the database was created.

{
  "created_at": "2017-08-08T03:09:06Z",
  "updated_at": "2025-01-17T02:24:14Z",
  "modified_at": "2017-08-08T03:09:05Z",
}

 

View solution in original post