If you have a residence permit valid for 12 months or longer you become entitled to National Registration and you can apply for a Swedish civic registration number. You must apply in person at the local Swedish Tax Agency. You will need to show your passport and proof of your residence permit.
Temporary residents and other persons not eligible for a Swedish civic registration number can obtain "coordination number", mainly for tax purposes. Note however, a "coordination number" entitles the holder only limited social welfare, health care etc. It is important therefore that these persons arrange adequate health insurance and other personal insurance coverage.