Can we set row-level permissions via APIs?

can we set row-level permissions via APIs ? I want to share a form with many users and I want to automate the process, I saw an example in the Documentation that performs the sharing via APIs but found nothing on raw level permissions.

I am interested in granting people the right to edit submissions based on a condition.

thanks!

Yes, if you go to https://[your server]/api/v2/assets/[your asset UID]/permission-assignments/, you will see some documentation under “Assign a permission” that includes:

POST /api/v2/assets/{uid}/permission-assignments/
…

Payload to assign partial permissions

   {   
      "user": "https://[kpi]/api/v2/users/{username}/",
      "permission": "https://[kpi]/api/v2/permissions/{partial_permission_codename}/",
      "partial_permissions": [
          {   
              "url": "https://[kpi]/api/v2/permissions/{codename}/",
              "filters": [
                  {"_submitted_by": {"$in": ["{username}", "{username}"]}}
              ]   
         },  
      ]   
   }   

N.B.:

  • Filters use Mongo Query Engine to narrow down results
  • Filters are joined with OR operator

“Partial permissions” is synonymous with row-level permissions.

Good luck! Remember, if you need a specific example for your use case, you can always observe the API requests sent by the application itself using your web browser’s developer console.

1 Like

Great! Thanks!

2 Likes