You can create custom fields through apex call by using Metadata API. Check below example that matches your requirement :- https://www.forcetalks.com/salesforce-topic/can-we-create-a-custom-field-through-salesforce-apex/#:~:text=You%20need%20to%20first%20generate,CustomField()%3B
Please mark as Best Answer so that it can help others in the future.
Hi Prashant,
You can create custom fields through apex call by using Metadata API.
Check below example that matches your requirement :-
https://www.forcetalks.com/salesforce-topic/can-we-create-a-custom-field-through-salesforce-apex/#:~:text=You%20need%20to%20first%20generate,CustomField()%3B
Please mark as Best Answer so that it can help others in the future.
Regards