URLs as Attributes?

I have a resource that has some urls as part of the data structure, and the client can post/patch these to set/update the urls.

Should these urls be part of the attributes? Or part of the links? I’m not sure where JSON:API stands on allowing resource links as part of the POST/PATCH payload


Are the URLs in your data arbitrary URLs, or do they represent relations among the resources & collections presented by your application?

If the former, they should just be attributes.

If the later, they should be presented using the corresponding properties in links objects. If they don’t correspond to the specific uses described in the specification, they should be considered arbitrary, and should not be added to links.

JSON:API 1.0 links are sufficiently anemic that it’s unlikely to be relevant outside the specific JSON:API usages described in the specification. I understand that’s going to be expanded in 1.1, but the defined link relations registered with IANA aren’t that interesting (mostly because each is too vague).

Or at least that’s my understanding from reading the specification.


Imagine you have a “user profile” resource, and as part of the user profile you want to allow the person to add a link to an avatar, or a link to their homepage. The avatar and homepage are external links, and don’t reference any other resource in our api.

Should links like these be part of the attributes, or links?

Definitely just attributes.

1 Like