If your application for a residence permit has been rejected, this means that you do not have the right to stay in Sweden. If the Swedish Migration Agency rejects your application while you are in Sweden, you will have a certain amount of time to leave Sweden.
The decision states the deadline by which you must leave. If you remain here after that date, you will be in the country illegally.
It is your responsibility to make sure you know what applies to you, so that you leave Sweden within the deadline stated in the decision.
You can appeal the Swedish Migration Agency’s decision. Information about how to appeal and the deadline for doing so is provided in the decision. If you choose to appeal, a court will review the decision.
If you have appealed the decision, in some cases you can stay in Sweden while you wait for the court’s decision. The decision states whether or not you have the right to stay in the country while your appeal is being examined.
Once the decision has come into force and can no longer be appealed, you must leave Sweden.
You need to plan your trip yourself and arrange for your passport and anything else you need in order to travel home.