Yes Abir, this is possible.
For the master object you can configure a trigger that creates and attaches related reocrds (assuming the related records also need to be newly created:) . Set this trigger timing as 'After Create'. Now whenever a master record is created via REST API, this trigger will run and attach related records for the newly created master record.
1. Create related record also via REST API. API will return Record ID of this newly created record.
2. Next when creating the master record, set the relationship/lookup field value with the record ID from previous step.
3. Depending on your requirement, i.e. create multipe records or single record, you may consider using one of createRecord or createArr Rest API for both related record creation and master record creation.