Api post content with reference asset


I have a small question on the api level.
I have a data schema with a reference to an asset (limited to 1 in the validation)
I would like to create a new content for this schema with the asset in api.
Question, should I upload the asset first and then get the id to create a content with the reference id?
Or can I create a content with the asset directly which will be automatically created with the reference validation controls (type, size, etc)?
I’m having trouble reading swagger in the object type needed for the reference which lists an array of string property names.

For info, I work in react 17 for the front end

Yes, you have to upload the asset first.

Each asset field is just an array of asset Ids:

Event when there is only one asset, it is an array.

As a result, if I configure validations such as file type, size, etc. in the schema that references the asset, I can’t use it to validate the image as I upload it directly from the asset endpoint.
Otherwise I have to get the schema config to get the validations and do this validation on the front end before creating the asset…

How do you mean that? The validation only happens after the asset is referenced not when it is uploaded.

I’ll explain my use case so you can understand.
On my site, I want to offer the possibility to an end user to add a photo in a gallery scheme.
I have defined validation rules on this reference with a maximum size and image types.
So if I upload an asset without control and try to add it in a “gallery” content, the addition can spit out because it doesn’t respect the validation rules.
I could then try to validate the file before uploading the asset with validations on the front end but I will be unstuck from the schema configuration.
So ideally, to centralize the verification, I would have to get the schema configuration with its validation, check the image on the front end before uploading and if ok everything will be fine for the rest.
A modification of the validation rules in squidex will be automatically taken care of on the front
Ideally, I should also get the default directory setting specified in the schema so that I upload the image to the right place…

Yes, something like this does not exist yet, we could think about a special endpoint but it is more work, because of all the special cases